title: Reading environment variables from .env file in pythonanywhere.com
body: <p>SOLVED: I was editing the wrong WISGI file. I didn't realize there was 2 separate WISGI files. Issue resolved. Thank you Forcebru for your help.</p>
  <p>I wrote an article detailing the process of <a href="https://engineertodeveloper.com/deploy-a-django-project-to-pythonanywhere/" rel="nofollow noreferrer">How to Deploy Django on PytonAnywhere</a>. Hopefully, that helps some people avoid the pitfalls I made.</p>
  <p>I am trying to set environment variables using a .env file in pythonanywhere.com but I keep getting an error saying my SECRET_KEY is empty so my environment variables aren't being set.</p>
  <p>I'm following the article from pythonanywhere.com</p>
  <p>link: <a href="https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/" rel="nofollow noreferrer">https://help.pythonanywhere.com/pages/environment-variables-for-web-apps/</a></p>
  <pre><code>import os
  from dotenv import load_dotenv
  project_folder = os.path.expanduser('~/my-project-dir')  # adjust as appropriate
  load_dotenv(os.path.join(project_folder, '.env'))
  </code></pre>
  <p>I don't quite understand the 3rd line. In the terminal, I cd into the project folder and run the pwd command to get the path. I'm not sure what part I am supposed to include for the argument for <code>os.path.expanduser('~/my-project-dir')</code>.</p>
  <p>Following the section for the bash console in the article, I had no trouble accessing my environment variables. So I think I am using the correct working project directory. I was able to echo to the console.</p>
  <p>Here's my WISGI file:</p>
  <pre><code>import os
  from dotenv import load_dotenv
  from django.core.wsgi import get_wsgi_application
  
  project_folder = os.path.expanduser('~/bogalusa-church')
  load_dotenv(os.path.join(project_folder, '.env'))
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bogalusa_church.settings')
  
  application = get_wsgi_application()
  </code></pre>
  <p>The working directory I used for setting up the variables for the bash terminal is the same one I am using here.</p>
  <p>Any insight is greatly appreciated. Thanks for any help in advance.</p>