ImportError: cannot import name RequestSite when inlude 'registration' in installed apps
ImportError: cannot import name RequestSite when inlude 'registration' in installed apps
我正在尝试安装 运行 Django-registration-redux,每当我尝试在已安装的应用程序中包含 'registration' 时,我都会收到错误消息:
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, in <module>
from django.contrib.sites.models import RequestSite
ImportError: cannot import name RequestSite
我在 myenv virtualenv 中新安装了 Django。 manage.py 运行 服务器工作正常,并且在不包含 'registration' 应用程序的情况下完美加载管理页面。 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',
]
你知道这里的问题是什么吗?
我运行进同样的错误(看看docs,Site
在django.contrib.sites.models
下,RequestSite
在[=15=下]).替换:
from django.contrib.sites.models import RequestSite
来自
from django.contrib.sites.requests import RequestSite
在 [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。
我正在尝试安装 运行 Django-registration-redux,每当我尝试在已安装的应用程序中包含 'registration' 时,我都会收到错误消息:
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, in <module>
from django.contrib.sites.models import RequestSite
ImportError: cannot import name RequestSite
我在 myenv virtualenv 中新安装了 Django。 manage.py 运行 服务器工作正常,并且在不包含 'registration' 应用程序的情况下完美加载管理页面。 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',
]
你知道这里的问题是什么吗?
我运行进同样的错误(看看docs,Site
在django.contrib.sites.models
下,RequestSite
在[=15=下]).替换:
from django.contrib.sites.models import RequestSite
来自
from django.contrib.sites.requests import RequestSite
在 [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。