使用Django密码小部件并在用户管理网站中更改密码形式 [英] Use Django password widget and change password form in user admin site

查看:57
本文介绍了使用Django密码小部件并在用户管理网站中更改密码形式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在扩展Django中的用户模型,并创建了一个PIN码字段,该字段正确地散列到数据库中.

I am extending the user model in Django and have create a PIN number field that is hashing into the database correctly.

但是,在Django admin中,当查看用户时,pin号字段将填充为散列.是否可以使用Django密码小部件:

However, in the Django admin when viewing a user the pin number field is populated with the hash. Is it possible to use the Django password widget:

以便不填充PIN号字段:

so that the PIN number field is not populated:

因此通过扩展使用更改密码表单的模板来更改密码吗?

and therefore by extension use the template for the change password form to also change the pin?

推荐答案

我不明白为什么您不能使用该表单.这是Django用户表单: django管理员中使用的.contrib.auth.forms.UserChangeForm .您想要的表单字段是 django.contrib.auth.forms.ReadOnlyPasswordHashField

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. The form field you want is django.contrib.auth.forms.ReadOnlyPasswordHashField

这篇关于使用Django密码小部件并在用户管理网站中更改密码形式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆