Python Django:RuntimeError:模型类django.contrib.sites.models.Site(错误继续)

时间:2016-01-10 19:31:59

标签: python django django-models

我目前正在使用Python Django编写一个Web应用程序。 我的问题是,我最近安装了django-relations, 将它添加到settings.py中的INSTALLED_APPS。

从那以后我收到了这个有线错误,我不知道这意味着什么。

有人可以帮助我吗?

Unhandled exception in thread started by <function wrapper at 0x10c6fdcf8>
Traceback (most recent call last):
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-packages/django/__init__.py", 
line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/relationships/models.py", line 3, in <module>
    from django.contrib.sites.models import Site
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/contrib/sites/models.py", line 83, in <module>
    class Site(models.Model):
  File "/Users/Maximilian_H/Documents/SkyPixelServernetzwerk/Coding-Projects/Website/lib/python2.7/site-
packages/django/db/models/base.py", line 102, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

1 个答案:

答案 0 :(得分:3)

似乎django-relationships取决于Site模型。您也必须将django.contrib.sites添加到INSTALLED_APPS

第二个错误表示django-relationships尝试从create_many_related_manager导入django.db.models.fields.related。在Django 1.9中删除了此功能。如果有更新的版本,您可以尝试这是否有效。如果没有,django-relationships不适用于Django 1.9。