简体   繁体   English

使用 Django 密码小部件并在用户管理站点中更改密码表单

[英]Use Django password widget and change password form in user admin site

I am extending the user model in Django and have create a PIN number field that is hashing into the database correctly.我正在 Django 中扩展用户模型,并创建了一个正确散列到数据库中的 PIN 码字段。

However, in the Django admin when viewing a user the pin number field is populated with the hash.但是,在 Django admin 中查看用户时,pin 号字段填充有哈希值。 Is it possible to use the Django password widget:是否可以使用 Django 密码小部件: 在此处输入图片说明

so that the PIN number field is not populated:以便不填充 PIN 码字段:

在此处输入图片说明

and therefore by extension use the template for the change password form to also change the pin?因此通过扩展使用更改密码表单的模板也可以更改密码?

I don't see why you couldn't use the form.我不明白你为什么不能使用表格。 Here's the Django User form: django.contrib.auth.forms.UserChangeForm that's used in the admin.这是管理员中使用的 Django 用户表单: django.contrib.auth.forms.UserChangeForm The form field you want is django.contrib.auth.forms.ReadOnlyPasswordHashField你想要的表单域是django.contrib.auth.forms.ReadOnlyPasswordHashField

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM