ImportError: cannot import name 'classproperty' - django

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

Related

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

django-disqus with django 1.4.8

I'm receiving this error when I add disqus to the INSTALLED_APP:
Error: No module named urllib.parse
I tracked this down to the following line:
from django.utils.http import urlencode
from django.utils.six.moves.urllib.error import URLError
from django.utils.six.moves.urllib.request import (
ProxyHandler,
Request,
urlopen,
build_opener,
install_opener
)
I know that six.moves is not included with django 1.4.8, is there any substitute?
Thanks
Six is an external library, which Django includes for convenience.
You could try installing six separately, and change the imports, for example change
from django.utils.six.moves.urllib.error import URLError
to
from six.moves.urllib.error import URLError

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

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)

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

Import Error : cannot import register

Getting Import error while trying to run localhost from my urls.py:
from django.conf.urls.defaults import *
from django.conf import settings
from django.http import HttpResponseRedirect
from django.contrib import admin
from mainapp.feeds import LatestReports, CityIdFeed, CitySlugFeed, WardIdFeed, WardSlugFeed,LatestUpdatesByReport
from mainapp.models import City
from social_auth.views import auth as social_auth
from social_auth.views import disconnect as social_disconnect
#Error at this line
from registration.views import register
from mainapp.forms import FMSNewRegistrationForm,FMSAuthenticationForm
from mainapp.views.account import SUPPORTED_SOCIAL_PROVIDERS
from django.contrib.auth import views as auth_views
from mainapp.views.mobile import open311v2
import mainapp.views.cities as cities
Traceback:
ImportError at /
cannot import name register
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.3
Exception Type: ImportError
Exception Value:
cannot import name register
Exception Location: /home/sourabh/Django/fixmystreet/fixmystreet/../fixmystreet/urls.py in <module>, line 9
Python Executable: /home/sourabh/Django/fixmystreet/bin/python
Python Version: 2.7.3
Python Path:
['/home/sourabh/Django/fixmystreet/fixmystreet',
'/home/sourabh/Django/fixmystreet/local/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
'/home/sourabh/Django/fixmystreet/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/sourabh/Django/fixmystreet/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg',
'/home/sourabh/Django/fixmystreet/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/home/sourabh/Django/fixmystreet/lib/python2.7',
'/home/sourabh/Django/fixmystreet/lib/python2.7/plat-linux2',
'/home/sourabh/Django/fixmystreet/lib/python2.7/lib-tk',
'/home/sourabh/Django/fixmystreet/lib/python2.7/lib-old',
'/home/sourabh/Django/fixmystreet/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/home/sourabh/Django/fixmystreet/local/lib/python2.7/site-packages',
'/home/sourabh/Django/fixmystreet/local/lib/python2.7/site-packages/PIL',
'/home/sourabh/Django/fixmystreet/lib/python2.7/site-packages',
'/home/sourabh/Django/fixmystreet/lib/python2.7/site-packages/PIL']
Server time: Thu, 22 Aug 2013 09:34:40 -0500
If you look at the docs you see that register is something that used to exist and was deprecated in the last version. From the documentation:
The 1.0 release of django-registration represents a complete rewrite
of the previous codebase, and introduces several new features which
[...]
You either downgrade to django-registration v0.8 (where registration.views.register still exists) or learn how to implement the changes to fit the newest version