python - How to use different view for django-registration? -
i have been trying django-registration use view registrationformuniqueemail , following solution django-registration question. have set urls.py
from django.conf.urls import patterns, include, url registration.forms import registrationformuniqueemail django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), (r'^users/', include('registration.backends.default.urls')), url(r'^users/register/$', 'registration.backends.default.views.registrationview', {'form_class': registrationformuniqueemail, 'backend': 'registration.backends.default.defaultbackend'}, name='registration_register'), )
however, can still create multiple accounts same email. problem? shouldn't django-registration using view specified? using django-registration 0.9b1.
the version of django registration using has been rewritten use class based views. means different approach required in urls.py.
first, need subclass registrationview, , set custom form class.
from registration.backends.default.views import registrationview registration.forms import registrationformuniqueemail class registrationviewuniqueemail(registrationview): form_class = registrationformuniqueemail
then, use custom registrationviewuniqueemail subclass in urls. other class based views, must call as_view().
url(r'^user/register/$', registrationviewuniqueemail.as_view(), name='registration_register'),
make sure customised registration_register view comes before include default registration urls, otherwise won't used.
Comments
Post a Comment