如何将Django-registration的此代码迁移到模块的1.0版本?

时间:2013-12-22 01:47:43

标签: django django-registration

我有一个运行旧版本Django-Registration的Django应用程序。在那个应用程序中,我用我自己创建的自定义注册表覆盖了正常的注册表单:

from myApp.forms import extendedRegistrationForm

# using my registration form to override the default
url (
    r'^accounts/register/$', 
    'registration.views.register',
    {
        'form_class': extendedRegistrationForm,
        'backend': 'registration.backends.default.DefaultBackend',
    }
),    

工作正常。但是,我现在正在迁移到当前版本的Django-registration,我被告知它没有名为registration.views.register的视图。相反,它有一个基于类的视图RegistrationView。所以我收到以下错误:

Could not import registration.views.register. View does not exist in module registration.views.

有人可以告诉我如何调整上面的代码以使用RegistrationView吗?

1 个答案:

答案 0 :(得分:2)

尝试

from registration.views import RegistrationView

register = RegistrationView.as_view()

url (
    r'^accounts/register/$', 
    register,
    {
        'form_class': extendedRegistrationForm,
        'backend': 'registration.backends.default.DefaultBackend',
    }
),