1

I am using Django 2. I am getting this error code, I have looked all over online and am not finding any answers to fix why it keeps giving me this error code.

Traceback (most recent call last):
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/management/base.py", line 366, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
    return import_module(self.urlconf_name)
  File "/home/matthew/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/matthew/mykoio/mykoio/urls.py", line 21, in <module>
    path('website/', include('website.urls')),
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "/home/matthew/anaconda3/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/matthew/mykoio/website/urls.py", line 3, in <module>
    from . import views
  File "/home/matthew/mykoio/website/views.py", line 6, in <module>
    from django.contrib.auth.forms import UserCreationForm
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 10, in <module>
    from django.contrib.auth.models import User
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/contrib/auth/models.py", line 3, in <module>
    from django.contrib.contenttypes.models import ContentType
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 134, in <module>
    class ContentType(models.Model):
  File "/home/matthew/anaconda3/lib/python3.6/site-packages/django/db/models/base.py", line 95, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

My installed apps are:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.auth.views',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

For some reason I have all the apps people are recommending, I try them and I get the same error code no matter what. All I can think now is there is something wrong with the Django code further in.

stidmatt
  • 1,629
  • 13
  • 15
  • Hi, could you please check this question: https://stackoverflow.com/questions/40206569/django-model-doesnt-declare-an-explicit-app-label ? I think it might be the same problem. – rje Oct 18 '18 at 19:32
  • By the way, it seems your project is named mykoio and it contains an app called website (right?), so why is this app not in installed_apps? – rje Oct 18 '18 at 19:42
  • OK, I tried doing the suggestions with the first question and I got the same error code. I try putting website into installed apps and it didn't fix anything. – stidmatt Oct 18 '18 at 19:45
  • Which suggestions did you try? And what does installed_apps look like now? – rje Oct 18 '18 at 19:47
  • INSTALLED_APPS = [ 'mykoio.apps.mykoioConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.auth.views', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mykoio.apps.website', ] – stidmatt Oct 18 '18 at 19:49
  • and I added class mykoioConfig(AppConfig): name = 'mykoio' verbose_name = 'MyKoio a new job app' to the bottom – stidmatt Oct 18 '18 at 19:49
  • Unfortunately I cannot help you any further with the info you are providing. The link I gave you shows a lot more possible solutions, I would suggest trying the other ones as well.. – rje Oct 18 '18 at 20:14
  • Errors seems to be related to File "/home/matthew/mykoio/website/urls.py", line 3, in from . import views File "/home/matthew/mykoio/website/views.py", line 6, in File "/home/matthew/mykoio/mykoio/urls.py", line 21, in path('website/', include('website.urls')), Provide a copy of these file so that we can help. – Stryker Oct 18 '18 at 20:46

1 Answers1

-1

INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.auth.views', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'website', ]

this should work.

anon
  • 17
  • 2