python - 从 django 注册表中删除第二个密码输入

标签 python django django-registration

我正在使用 django-registration v1.0 进行注册。默认情况下,注册页面有 4 个输入字段:

  • 用户名
  • 电子邮件
  • 密码1
  • 密码2

django-registration documentation证明重复输入密码是为了捕捉拼写错误。但我想删除第二个密码字段。

我该怎么做?

最佳答案

这就是我让它工作的方式,以防它对某人有帮助:

forms.py

from registration.forms import RegistrationForm

class UserRegistrationForm(RegistrationForm):
    def __init__(self, *args, **kwargs):
        super(RegistrationForm, self).__init__(*args, **kwargs)
        self.fields.pop('password2')

views.py

from registration.backends.simple.views import RegistrationView
from .forms import UserRegistrationForm

class MyRegistrationView(RegistrationView):
    form_class= UserRegistrationForm

urls.py

from links.views import MyRegistrationView

url(r'^register/$', MyRegistrationView.as_view(), name='register'),

感谢 karthikr 的评论。

关于python - 从 django 注册表中删除第二个密码输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25835424/

相关文章:

python - Django 1.5 的多种用户类型、自定义字段和共享身份验证

python - 如何在 Python 中仅使用列表而不使用字典将城市与国家/地区关联起来?

python - google colab 上的 pyodbc

python - 在 Django 1.9 中我应该使用什么来代替 syncdb?

javascript - 添加 javascript 和 jquery 的 Django 模板

python - 完整性错误 : update or delete violates foreign key constraint. Django + PostgreSQL

python - Django 在密码重置时收到意外的关键字参数 uidb36

Django 注册 - 没有名为简单错误的模块

Python 名称错误 : Name is not defined Linux

python - `python setup.py sdist` 与 cython 扩展 : . pyx ' doesn' t 匹配任何文件