1

I am customizing the django-registration module. So far I am passing the url like

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"),


)

When the url is requested I get the error No module named django.views and it is not going to the success_url.

I think i am doing something wrong in urls.py but I can't see what. Please help me out.

Thanks in advance.

4

1 回答 1

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',
    ),

我在这里没有使用命名的 URL,但是使用硬编码的 URL 可以更容易地让它工作,并在您确定其他一切正常时将其更改为命名。

于 2014-08-20T09:30:44.540 回答