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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)