-1

尝试从我的 localhost 运行时出现导入错误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

追溯:

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
4

1 回答 1

1

如果您查看文档,您会发现 register 曾经存在并且在上一个版本中已被弃用。从文档中:

django-registration 的 1.0 版本代表了对以前代码库的完全重写,并引入了几个新特性,这些特性 [...]

您要么降级到 django-registration v0.8(registration.views.register 仍然存在),要么学习如何实施更改以适应最新版本

于 2013-08-22T15:16:15.153 回答