Pythonanywhere Wsgi Error
in spite of my best efforts in the past weeks I've been stuck at deploying the WSGI file on Pythonanywhere while trying to set up a django framework. There are similar topics on he
Solution 1:
As the error says, your DJANGO_SETTINGS_MODULE environment variable is set to "mysite", but that directory does not exist. Your settings file actually appears to be in "firstweb".
Solution 2:
follow it
Start by saving your environment variables into a .env file in your project folder You can run something like this in a Bash console, or edit the .env file directly using our "Files" tab:
cd ~/my-project-dir
echo"export SECRET_KEY=sekritvalue" >> .envecho"export OTHER_SECRET=somethingelse" >> .env
Install python-dotenv into your virtualenv workon my-virtualenv-name
pip install python-dotenv
or, if you're not using a virtualenv:
pip3.6 install --user python-dotenv
and, optionally, add it to your requirements.txt, if you're using one:
echo python-dotenv >> requirements.txt
and in wsgi file before get_wsgi_application()
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'))
and make changes in setting.py file and remove secret key and put
import os
SECRET_KEY = os.getenv("SECRET_KEY")
and at last, do in bash console
set -a; source ~/my-project-dir/.env; set +a
echo'set -a; source ~/my-project-dir/.env; set +a' >> ~/.virtualenvs/my-project-virtualenv/bin/postactivate
all done remove wsgi related error
Post a Comment for "Pythonanywhere Wsgi Error"