我正在使用Python 3.6.0、Django 1.10.6和Oscar 1.4.0最终版本。
我看到过一些类似的错误消息被讨论和报告,这些消息被某些解决方案解决了(例如,更新"仍然"是旧的自动生成的wsgi.py),或者几乎在顶部附近添加import django
和django.setup()
(即,在SECRET_KEY
和INSTALLED_APPS
之前,向上移动到顶部附近)。我在Github上发现了与错误消息更接近的匹配项,为了Raven的目的,人们可以在那里从他们的项目中删除标准用户或身份验证模块。然而,我还没有找到一个有人报告错误的地方,除了从一个无关的基于Django的项目中删除一个标准Django应用程序之外,还有其他解决方案。
特定的错误消息和跟踪并没有告诉我有问题的行,除了怀疑它是由INSTALLED_APPS中包含的"django.contrib.contenttypes"触发的之外。当我尝试运行它时,我得到的跟踪是:
(store env)~/store$python manage.py migrate追踪(最近一次通话):文件"manage.py",第22行,在<模块>execute_from_command_line(sys.argv)文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/_init__.py",第367行,在execute_from_command_line中utility.execute()文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/__init__.py",第359行,执行中self.fetch_command(子命令).run_from_argv(self.argv)run_from_argv中的文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/base.py",第294行self.execute(*args,**cmd_options)文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/base.py",第342行,执行中self.check()文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/base.py",第374行,检查中include_deployment_checks=包含部署检查,文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/commands/migrate.py",第62行,在_run_checks中issues.extend(super(Command,self)_run_checks(**kwargs))文件"/Users/christos/store env/lib/python3.6/site packages/django/core/management/base.py",第361行,在_run_checks中return checks.run_checks(**kwargs)run_checks中的文件"/Users/christos/store env/lib/python3.6/site packages/django/core/checks/registry.py",第81行new_errors=检查(app_configs=app_configs)check_url_config中的文件"/Users/christos/store env/lib/python3.6/site packages/django/core/checks/urls.py",第14行返回check_resolver(解析程序)check_resolver中的文件"/Users/christos/store env/lib/python3.6/site packages/django/core/checks/urls.py",第24行对于resolver.ul_patterns中的模式:文件"/Users/christos/store env/lib/python3.6/site packages/django/utils/functional.py",第35行,位于__get__res=实例__dict__[self.name]=self.func(实例)文件"/Users/christos/store env/lib/python3.6/site packages/django/urls/resolvers.py",第313行,在url_patterns中patterns=getattr(self.urlconf_module,"urlpatters",self.urlconf_module)文件"/Users/christos/store env/lib/python3.6/site packages/django/utils/functional.py",第35行,位于__get__res=实例__dict__[self.name]=self.func(实例)urlconf_module中的文件"/Users/christos/store env/lib/python3.6/site packages/django/urls/resolvers.py",第306行return import_module(self.urlconf_name)import_module中的文件"/Users/christos/store env/lib/python3.6/importlib/_init__.py",第126行return bootstrap_gcd_import(名称[level:],包,级别)_gcd_import中的文件"<冻结的importlib_bootstrap>",第978行文件"<冻结的importlib_bootstrap>",第961行,在_find_and_load中文件"<冻结的importlib_bootstrap>",第950行,在_find_and_load_unlocked中文件"<冻结的importlib_bootstrap>",第655行,在_load_unlocked中exec_module中的文件"<冻结的importlib_bootstrap_external>",第678行文件"<冻结的importlib_bootstrap>",第205行,在_call_with_frames_removed中文件"/Users/christos/store/urls.py",第18行,在<模块>来自oscar.app导入应用程序文件"/Users/christos/store env/lib/python3.6/site packages/soscar/app.py",第5行,在<module>从django.contrib.auth导入视图作为auth_views文件"/Users/christos/store env/lib/python3.6/site packages/django/contrib/auth/views.py",第11行,在<模块>从django.contrib.auth.forms导入(文件"/Users/christos/store env/lib/python3.6/site packages/django/contrib/auth/forms.py",第12行,在<模块>从django.contrib.auth.models导入用户文件"/Users/christos/store env/lib/python3.6/site packages/django/contrib/auth/models.py",第6行,在<module>从django.trib.contenttypes.models导入ContentType文件"/Users/christos/store env/lib/python3.6/site packages/django/contrib/contenttypes/models.py",第138行,在<模块>类ContentType(models.Model):文件"/Users/christos/store env/lib/python3.6/site packages/django/db/models/base.py",第113行,__new__"INSTALLED_APPS。"%(模块,名称)RuntimeError:模型类django.contrib.conttypes.models.ContentType没有声明显式app_label,也不在INSTALLED_APPS中的应用程序中。(store-env)~/store$
我当前的settings.py
,从据报道对SO上的其他人有效的内容进行了有益或无益的修改,最多是一个未受影响的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
我该怎么办才能让奥斯卡拥有它应该得到的所有应用程序?
'django.contrib.sites.models.Site',
'django.contrib.contenttypes.models.ContentType'
这不应该出现在已安装的应用程序部分。这些是模型,安装的应用程序部分主要用于应用程序。