Open danmir opened 9 years ago
RegistrationView
use get_form_class()
method to get the registration form class, not form_class
attribute. That's why overriding form_class
didn't work.
In the method, self.backend.get_registraion_form_class()
is called and the method in a default backend returns RegistrationForm
.
So what you need to do is
registration.backends.DefaultRegistrationBackend
to create your backend class (say your_registration.backends.MyRegistrationBackend
)get_registration_form_class()
method to return your form class (say your_registration.forms.MyRegistrationForm
).REGISTRATION_BACKEND_CLASS
in settings.py
(See registration.backends to figure out how django-inspectional-registration find backend class)# your_registration/backends.py
from registration.backends.default import DefaultRegistrationBackend
from your_registration.forms import MyRegistrationForm
class MyRegistrationBackend(DefaultRegistrationBackend):
def get_registration_form_class(self):
# do not return an instance, return class
return MyRegistrationForm
# settings.py
REGISTRATION_BACKEND_CLASS = 'your_registration.backends.MyRegistrationBackend'
Thank you so much for your answer. And is it possible to validate supplement class form ?
registration.supplements.base.RegistrationSupplementBase
, which must be inherited to use supplement feature, have get_form_class
class method which return form_class
attribute of the class. So
class MyRegistrationSupplement(RegistrationSupplementBase):
form_class = MyRegistrationSupplementForm
should work.
Hum... RegistrationSupplementBase support attribute assignment but RegistrationView. Basically RegistrationView came from django-registration a long time ago thus some legacy codes are remained. I may allow users to do attribute assignments even in RegistrationView which is possible in django-registration can now days.
ping @danmir
Hello. Could you help me with the form validation and Supplement form validation. How could I do that ? My full question on stackoverflow. Thank you.