Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name RequestSite when inlude 'registration' in installed apps

I am trying to install and run Django-registration-redux and whenever I try to include 'registration' in installed apps I am getting an error:

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

I have freshly installed Django in myenv virtualenv. manage.py runserver is working fine and loading admin page perfectly without 'registration' app included. FYR: I am using python27 and here is my pip freeze for myenv:

> pip freeze
Django==1.9
django-registration-redux==1.2
wheel==0.24.0

and settings.py inludes the following apps:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'registration',
]

Do you have any idea on what is the problem here?

like image 787
unixbek Avatar asked Dec 13 '15 11:12

unixbek


2 Answers

I ran into the same error (take a look at the docs, Site is under django.contrib.sites.models and RequestSite under django.contrib.sites.requests). Replace :

from django.contrib.sites.models import RequestSite

by

from django.contrib.sites.requests import RequestSite

in [YourPath]/admin.py, (it's C:\Users\AdamSmith\projects\myvenv\lib\site-packages\registration\admin.py in your case).

like image 195
issathink Avatar answered Nov 06 '22 22:11

issathink


This issue is fixed in django-registration-redux 1.3. See https://github.com/macropin/django-registration/issues/132.

like image 43
Rolf H Nelson Avatar answered Nov 06 '22 22:11

Rolf H Nelson