Read a .env file into os.environ.

    If not given a path to a envfile path, does filthy magic stack backtracking
    to find manage.py and then find the envfile.

def read_environment_file(envfile=None):
    """
    Read a .env file into os.environ.

    If not given a path to a envfile path, does filthy magic stack backtracking
    to find manage.py and then find the envfile.
    """
    if envfile is None:
        frame = sys._getframe()
        envfile = os.path.join(os.path.dirname(frame.f_back.f_code.co_filename), '.env')
        if not os.path.exists(envfile):
            warnings.warn("not reading %s - it doesn't exist." % envfile)
            return
    for k, v in parse_environment_file(envfile):
        os.environ.setdefault(k, v)