Django-registration模块success_url没有返回

时间:2012-07-31 08:56:13

标签: python django django-registration

我正在定制django-registration模块。到目前为止,我正在传递像

这样的网址
from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

from django.contrib import admin
admin.autodiscover()
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
import registration.backends.default.urls as regUrls

from profile import UserRegistrationForm
from registration.views import register
import regbackend, views
from accounts import profile
urlpatterns = patterns('',     
  #  (r'^conf/admin/(.*)', admin.site.root),
    url(r'^register/$', register, {'backend': 'registration.backends.default.DefaultBackend','success_url':profile,'form_class': UserRegistrationForm}, name='registration_register'),
    (r'^accounts/', include(regUrls)),
    url('^profile/$', direct_to_template, {'template': 'profile.html'}, name="profile"),


)

当请求网址时,我收到错误No module named django.views,而不是success_url

我认为我在urls.py做错了什么,但我看不清楚是什么。请帮帮我。

提前致谢。

1 个答案:

答案 0 :(得分:0)

尝试更改此行:

url(r'^register/$', register, {'backend': 'registration.backends.default.DefaultBackend','success_url':profile,'form_class': UserRegistrationForm}, name='registration_register'),

对此:

url(r'^register/$',
    RegistrationView.as_view(
        form_class=UserRegistrationForm,
        success_url='profile/',),
    name='registration_register',
    ),

我在这里没有使用过命名的网址,但是使用硬编码的网址可以更容易地使用它,并且当您确定其他所有内容都有效时,将其更改为已命名的网址。