尝试运行python manage.py runserver
时我收到以下错误:
Unhandled exception in thread started by <function wrapper at 0x103828e60>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/registration/admin.py", line 2, in <module>
from django.contrib.sites.models import RequestSite
ImportError: cannot import name RequestSite
我正在运行Django 1.10和Python 2.7。
答案 0 :(得分:0)
Tomcat's classloader documentation不在sites.models中。
根据RequestSite
自1.7以来已被弃用
自1.7版以来已弃用:
此类曾在django.contrib.sites.models中定义。旧的导入位置将一直有效,直到Django 1.9。
可以在
找到django.contrib.sites.requests.RequestSite
假设您正在使用热门django-registration-redux
,其最新版本的版本为1.8 docs,因此如果是这种情况,您应该更新该版本。