Pregunta

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
¿Fue útil?

Solución

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top