Django-Registration 在 forms.py 文件中有几个表单类。一是“类 RegistrationFormTermsOfService(RegistrationForm) ..
我需要对 Django 注册代码的其余部分进行哪些更改才能在我的注册流程中启用此表单而不是 RegistrationForm?
最佳答案
更新接受的答案以符合 Django 1.5 和最新版本的 django-registration:
在 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 ...
)
然后更新registration_form.html模板并添加tos
字段,例如:
<p>
<label for="id_tos">I accept the terms of service</label>
{% if form.tos.errors %}
<p class="errors">{{ form.tos.errors.as_text }}</p>
{% endif %}
{{ form.tos }}
</p>
关于django - 如何在 Django-Registration 中使用不同的表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6414926/