我正在尝试安装并运行Django-registration-redux,每当我尝试在已安装的应用程序中包含"注册"时,我都会收到错误消息:
Traceback (most recent call last): File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\utils\autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\apps\registry.py", line 115, in populate app_config.ready() File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\contrib\admin\apps.py", line 22, in ready self.module.autodiscover() File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover autodiscover_modules('admin', register_to=site) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\django\utils\module_loading.py", line 50, in autodiscover_modules import_module('%s.%s' % (app_config.name, module_to_search)) File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module __import__(name) File "C:\Users\AdamSmith\projects\myvenv\lib\site-packages\registration\admin.py", line 2, infrom django.contrib.sites.models import RequestSite ImportError: cannot import name RequestSite
我已经在myenv virtualenv中新安装了Django.manage.py runserver工作正常,加载管理页面完美,没有包含"注册"应用程序.FYR:我使用的是python27,这是myenv的pip冻结:
> pip freeze Django==1.9 django-registration-redux==1.2 wheel==0.24.0
和settings.py包含以下应用程序:
INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'registration', ]
你对这里的问题有什么想法吗?
我遇到了同样的错误(看看文档,Site
是在下面django.contrib.sites.models
和RequestSite
下面django.contrib.sites.requests
).替换:
from django.contrib.sites.models import RequestSite
通过
from django.contrib.sites.requests import RequestSite
in [YourPath]/admin.py
,(C:\Users\AdamSmith\projects\myvenv\lib\site-packages\registration\admin.py
在你的情况下).
此问题已在django-registration-redux 1.3中修复.请参阅https://github.com/macropin/django-registration/issues/132.