I am working with Python 3.6.0, Django 1.10.6, and Oscar version 1.4.0 final.
I've seen similar-looking error messages discussed and reported solved by certain solutions (e.g. updating what was "still" an old-time autogenerated wsgi.py), or adding import django
and django.setup()
almost near the top (i.e. before SECRET_KEY
and INSTALLED_APPS
, moved up near the top). I've found closer matches to the error message on Github, where for the purposes of Raven people have been given the all-clear to delete standard user or authentication modules from their project. However, I have not found a place where someone reports the error and there is a solution other than an all-clear to delete a standard Django app from an unrelated Django-based project.
The specific error message and trace does not shout out to me what line is at issue beyond suspicions it is being triggered by inclusion of 'django.contrib.contenttypes' in INSTALLED_APPS. The trace I get when I try to run it is:
(store-env) ~/store $ python manage.py migrate Traceback (most recent call last): File "manage.py", line 22, in <module> execute_from_command_line(sys.argv) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 342, in execute self.check() File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 62, in _run_checks issues.extend(super(Command, self)._run_checks(**kwargs)) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/management/base.py", line 361, in _run_checks return checks.run_checks(**kwargs) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/urls.py", line 14, in check_url_config return check_resolver(resolver) File "/Users/christos/store-env/lib/python3.6/site-packages/django/core/checks/urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "/Users/christos/store-env/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Users/christos/store-env/lib/python3.6/site-packages/django/urls/resolvers.py", line 313, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/Users/christos/store-env/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "/Users/christos/store-env/lib/python3.6/site-packages/django/urls/resolvers.py", line 306, in urlconf_module return import_module(self.urlconf_name) File "/Users/christos/store-env/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/christos/store/store/urls.py", line 18, in <module> from oscar.app import application File "/Users/christos/store-env/lib/python3.6/site-packages/oscar/app.py", line 5, in <module> from django.contrib.auth import views as auth_views File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/views.py", line 11, in <module> from django.contrib.auth.forms import ( File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 12, in <module> from django.contrib.auth.models import User File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/auth/models.py", line 6, in <module> from django.contrib.contenttypes.models import ContentType File "/Users/christos/store-env/lib/python3.6/site-packages/django/contrib/contenttypes/models.py", line 138, in <module> class ContentType(models.Model): File "/Users/christos/store-env/lib/python3.6/site-packages/django/db/models/base.py", line 113, 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. (store-env) ~/store $
My current settings.py
, helpfully or unhelpfully modified from what reportedly worked for others on SO, is, up to an untouched import os
:
from oscar.defaults import *
from django.conf import settings
settings.configure()
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '[DELETED]'
from oscar import get_core_apps
INSTALLED_APPS = [
#'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.flatpages',
'django.contrib.sites.models.Site',
'django.contrib.contenttypes.models.ContentType',
'compressor',
'widget_tweaks'
] + get_core_apps()
import django
django.setup()
"""
Django settings for store project.
Generated by 'django-admin startproject' using Django 1.10.6.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
What can/should I do that Oscar has all the apps that it should be getting?