How to update admin.py in django-registration-redux? - django

RequestSite is no longer in django.contrib.sites.models but is in django.contrib.sites.requests. I found that when I installed django-registration-redux, those old import statements are still there. So it raises the following errors:
from django.contrib.sites.models import RequestSite
ImportError: cannot import name 'RequestSite'
So how can I fix it? How do I replace RequestSite in python3.4/site-packages/registration/admin.py file? I am using django-registration-redux 1.2, Django 1.9 and Python 3.4.

RequestSite is under django.contrib.sites.requests
so replace: from django.contrib.sites.models import RequestSite
with: from django.contrib.sites.requests import RequestSite
Reference: (https://docs.djangoproject.com/en/1.9/ref/contrib/sites/#requestsite-objects)

Related

ImportError: cannot import name 'url' from 'django.conf.urls'

ImportError: cannot import name 'url' from 'django.conf.urls' (/home/chams/pfe_project/CarApp/venv/lib/python3.8/site-packages/django/conf/urls/_init_.py)
I can't find any mistakes in my code !
django.conf.urls.url was deprecated and removed in Django 4.0.
Use django.urls.re_path instead.
django.conf.urls.url() was deprecated in Django 3.0, and is removed in Django 4.0+.
The easiest fix is to replace url() with re_path()
You will be using this,
from django.conf.urls import url
Instead use this:
from django.urls import re_path as url
for Django 4.0.
from django.urls import re_path as url

No module named django.core.urlresovers in django 2.0a1

Have recently upgraded from django 1.11.7 to django 2.0a1 and now cannot import reverse_lazy
File "/home/silasi/Deprojecto/eljogo/jogos/views.py", line 8, in <module>
from django.core.urlresolvers import reverse_lazy
ModuleNotFoundError: No module named 'django.core.urlresolvers'
In Django 2.0 you must import:
from django.urls import reverse_lazy
Since version 1.10 django.core.urlresolvers was deprecated, change the import to
from django.urls import reverse_lazy
more information about 1.10 version,
more info about django.urls

ImportError: cannot import name 'classproperty'

What is the solution of this error........
from django.utils.decorators import classproperty
ImportError: cannot import name 'classproperty'
Why this error shows. How can I solve this problem ?
If you have this issue after 21 Oct 2019 that is because in this PullRequest classproperty were moved from django.utils.decorators to django.utils.functional.
You need to change your import statement or add some code to check what version of django are you using and from where to import the classproperty
try:
# Django 3.1 and above
from django.utils.functional import classproperty
except ImportError:
from django.utils.decorators import classproperty
Check your django version. This module is not there before django 1.9

ImportError : cannot import name AppCache

I have installed Django 1.8.3 Then i created my project. I need to import the AppCache but not able to import it. In Django shell i wrote
from django.db.models.loading import AppCache
Error is:
ImportError: cannot import name AppCache
Please help me out.
AppCache is not a part of django.db.models.loading from django 1.7 onwards.For more information you can read this link

django on jython(cannot import name BaseDatabaseWrapper)

I have a problem buliding django on jython
I have already installed django-jython , jython , django
in settings.py dababase engine I write : doj.db.backends.sqlite
raiseImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured:
'doj.db.backends.sqlite' isn't an
available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: cannot import name BaseDatabaseWrapper
it seems that in doj.db there is no these classes which I can find in django.db
and I find in site-packages\django_jython-1.7.0b2-py2.7.egg\doj\db\backends\sqlite\base.py
there are :
from doj.db.backends import JDBCBaseDatabaseWrapper as BaseDatabaseWrapper
from doj.db.backends import JDBCBaseDatabaseFeatures as BaseDatabaseFeatures
from doj.db.backends import JDBCBaseDatabaseOperations as BaseDatabaseOperations
from doj.db.backends import JDBCCursorWrapper as CursorWrapper
from doj.db.backends import JDBCConnection
maybe the problem lies here
thanks for your help
I got the same problem. It's Django compatibility issue indeed. django-jython 1.7 works with Django 1.7.x (see https://pythonhosted.org/django-jython/release-notes.html#b2)