Use Django password widget and change password form in user admin site

落爺英雄遲暮 提交于 2021-02-11 17:09:53

问题


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

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:

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?


回答1:


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



来源:https://stackoverflow.com/questions/59790374/use-django-password-widget-and-change-password-form-in-user-admin-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!