title: django 2 not able to load env variables from the .env file to setting.py file
body: <p>I tried to load environment variables from a file named .env to settings.py file 
  here i created the .env file and settings file same folder.</p>
  
  <p>this is my .env file </p>
  
  <pre><code>DEBUG=on
  SECRET_KEY=ksmdfw3324@#jefm
  DATABASE_URL=psql://urser:un-githubbedpassword@127.0.0.1:8458/database
  SQLITE_URL=sqlite:///my-local-sqlite.db
  CACHE_URL=memcache://127.0.0.1:11211,127.0.0.1:11212,127.0.0.1:11213
  REDIS_URL=rediscache://127.0.0.1:6379/1? 
  client_class=django_redis.client.DefaultClient&amp;password=ungithubbed-secret
  
  
  MYSQL_DATABASE = student
  MYSQL_USERNAME = root 
  SECRET_KEY=secret-key
  </code></pre>
  
  <p>this is my setting.py file</p>
  
  <pre><code>import os
  
  from os.path import join, dirname
  from dotenv import load_dotenv
  
  dotenv_path = join(dirname(__file__), '.env')
  
  load_dotenv(dotenv_path)
  
  # Accessing variables.
  dbname = os.getenv('MYSQL_DATABASE')
  secret_key = os.getenv('SECRET_KEY')
  
  # Using variables.
  print(dabname)
  print(secret_key)
  </code></pre>
  
  <p>i installed <code>pip install -U python-dotenv</code> </p>
  
  <p>Issue is i am not able to get environment variable inside settings file</p>
  
  <p>while trying <code>python manage.py runserver</code> i am getting this error</p>
  
  <pre><code>C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\dotenv\main.py:65: UserWarning: File doesn't exist
  warnings.warn("File doesn't exist {}".format(self.dotenv_path))
  Traceback (most recent call last):
  File "manage.py", line 28, in &lt;module&gt;
  execute_from_command_line(sys.argv)
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\django\core\management\__init__.py", line 371, in 
  execute_from_command_line
  utility.execute()
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\django\core\management\__init__.py", line 317, in execute
  settings.INSTALLED_APPS
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\django\conf\__init__.py", line 56, in __getattr__
  self._setup(name)
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\django\conf\__init__.py", line 43, in _setup
  self._wrapped = Settings(settings_module)
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\django\conf\__init__.py", line 106, in __init__
  mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36- 
  32\lib\importlib\__init__.py", line 126, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)
  File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
  File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked
  File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked
  File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
  File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
  File "C:\xampp\htdocs\epitastudent\epitastudent\settings.py", line 25, in 
  &lt;module&gt;
  load_dotenv()
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\dotenv\main.py", line 255, in load_dotenv
  return DotEnv(f, 
  verbose=verbose).set_as_environment_variables(override=override)
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\site- 
  packages\dotenv\main.py", line 98, in set_as_environment_variables
  os.environ[k] = v
  File "C:\Users\mehul\AppData\Local\Programs\Python\Python36-32\lib\os.py", 
  line 675, in __setitem__
   self.putenv(key, value)
   ValueError: embedded null character
  </code></pre>
  
  <p>I am not sure how to create development and production environment variable and about this embedded null character. pls help me any one 
  Thanks in advance   </p>
  
  <p>Edit: I got now .env file to inside settings</p>
  
  <pre><code>import os
  import environ
  root = environ.Path(__file__) - 3 # three folder back (/a/b/c/ - 3 = /)
  env = environ.Env(DEBUG=(bool, False),) # set default values and casting
  environ.Env.read_env() # reading .env file
  print(os.getenv('DATABASE_NAME'))
  </code></pre>
  
  <p>How can i differentiate development env credentials and production credentials</p>