Django-registration display setting

I am using django-registration (see https://bitbucket.org/ubernostrum/django-registration ) in one of my projects. The standard installation for registering django is to add the code below to the urls.py file

 (r'^accounts/', include('registration.urls')) 

as well as configure templates in the registration folder.

In the above code, registration links, login and password are created, and this is normal. But there are some other functions in my project that I usually add to my views, so if I just add include('registration.urls') , it seems like I have no way to customize the views containing these django registration forms.

Is there a way to invoke the forms used by django-registration in a view so that I can add a few more things to these views?

+4
source share
1 answer

The registration form is provided by the registration backend. Check registration.backends.default.DefaultBackend .

There is a get_form_class(request) method that returns a registration.forms.RegistrationForm class. All you have to do is create a new backend, inherit from DefaultBackend and override the get_form_class() method to return a new form class.

You can pretty much do something by providing a custom backend, with the exception of changing the basic behavior of the registration application. If you need to radically customize your views so that you can back up custm, do not create a slice, just create an authn or users application and import any bits from the django registration that you find useful. You can, say, save the default models and managers in the registration application namespace, but connect your own backend to your internal devices in the new application.

+6
source

Source: https://habr.com/ru/post/1338971/


All Articles