How to use different form in Django-Registration

后端 未结 5 1549
小蘑菇
小蘑菇 2021-02-15 15:39

Django-Registration has several form classes in the forms.py file. One is \"class RegistrationFormTermsOfService(RegistrationForm) ..

What do I change in the rest of Dja

5条回答
  •  渐次进展
    2021-02-15 16:18

    Updating the accepted answer to conform with Django 1.5 and the latest version of django-registration:

    in urls.py:

    from registration.forms import RegistrationFormTermsOfService
    from registration.backends.default.views import RegistrationView
    
    urlpatterns = patterns('',
        url(r'^accounts/register/$', RegistrationView.as_view(form_class=RegistrationFormTermsOfService), name='registration_register'),
        # your other URLconf stuff follows ...
    )
    

    then update the registration_form.html template and add a tos field, e.g.:

    {% if form.tos.errors %}

    {{ form.tos.errors.as_text }}

    {% endif %} {{ form.tos }}

提交回复
热议问题