1

i am getting the following error when trying to run the django 2 app

few lines from stacktrace

File "/Users/shobi/Projects/emailtool/emailtool/frontend/models/AwsSettings.py", line 4, in

from emailtool.frontend.models.AwsRegions import AwsRegions File "/Users/shobi/Projects/emailtool/emailtool/frontend/models/AwsRegions.py", line 4, in

class AwsRegions(models.Model): File "/Users/shobi/Projects/emailtool/env/lib/python3.6/site-packages/django/db/models/base.py",

line 108, in new

"INSTALLED_APPS." % (module, name) RuntimeError: Model class emailtool.frontend.models.AwsRegions.AwsRegions doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

I tried

Django: Model class user.models.Users doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

and many google results as well, what is missing?

Django2, Python 3.6

Edit:

INSTALLED_APPS = [
    'frontend',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
Shobi
  • 10,374
  • 6
  • 46
  • 82

1 Answers1

1

I figured it out after trying all the possible Stackoverflow answers.

In some of my views/forms I was requiring this model called AwsRegions, Initially all the models were inside a single file which later moved to a separate folder called models/ and I updated the other existing code which was requiring this class.

After some time the problem which is specified in the question came while trying the runserver command. (I suppose the pycache was giving older files before, so it was not throwing any error.).

But this error was not making any sense at all.

Then I tried to run python3 manage.py makemigrations command, and it started throwing errors, then I went and fixed those errors, those were simple file not found errors due to invalid paths. after that i tried python3 manage.py runserver and it ran successfully.

So, In essence

  1. Run python3 manage.py makemigrations
  2. Fix the incoming errors
  3. Run python3 manage.py makemigrations again
Shobi
  • 10,374
  • 6
  • 46
  • 82