I have created a blog with django by following some book. The django website works but the terminal keeps on showing this message if i try to interpret the code on spyder(setting.py, models.py)
ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Here ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings the solution which was given for this was: set DJANGO_SETTINGS_MODULE=mysite.settings as in the documentation for django. However if i stop the server and restart it after running the code i am still getting the same error. Could you please advise what setting it is referring to which are not configured?
This is perticularly odd because it prints out the same error message if I run this help(models.DateTimeField)
-Edit-
manage.py looks like this:
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.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)
if __name__ == '__main__':
main()