Question

I have a Django application running an older version Django-Registration. In that application, I'm overriding the normal registration form with a custom one that I have created like so:

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

It works fine. However, I am now migrating to the current version of Django-registration which I'm told does not have a view named registration.views.register. Instead it has a class-based view RegistrationView. So I get the following error:

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

Can someone show me how to adapt my code above to work with RegistrationView?

Était-ce utile?

La solution

Try

from registration.views import RegistrationView

register = RegistrationView.as_view()

url (
    r'^accounts/register/$', 
    register,
    {
        'form_class': extendedRegistrationForm,
        'backend': 'registration.backends.default.DefaultBackend',
    }
),  
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top