I am in the process on getting started with python and have run into a problem using django 2.1 and python 3.7 that many other people seem to have had as well.
Below is my process for getting here:
started a virtual environment
started a django project
attempted to run:
python manage.py runserver
I consistently get the error : ModuleNotFoundError: No module named 'settings'
I've researched extensively to and came across a few solutions in the following SO questions, none of which were effective solutions for me. Has anyone come across this issue?
First question researched
Second Question researched
Any insight would be helpful. Thanks in advance.
EDIT: my manage.py file looks like this:
#!/usr/bin/env python import os import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mytodoapp.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
my file structure looks like :
mytodoapp
mytodoapp
>__init__.py >settings.py >urls.py >wsgi.pymanage.py
Screenshot of my console
Manage.py file
open yr project folder.
search for the wsgi.py file and add this line.
from django.conf import settings.
Then save.
locate yr manage.py file edit the
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projectname.settings')
To
os.environ['DJANGO_SETTINGS_MODULE' ]='projectname.settings'
save and walla problem fixed.
cd to yr app folder and then runserver
with
python manage.py runserver.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With