覆盖 django-admin 编辑加密数据的表单字段值 [英] Override django-admin edit form field values for encrypted data

查看:17
本文介绍了覆盖 django-admin 编辑加密数据的表单字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库中有加密的值,如何覆盖 django 的管理员编辑表单,以便字段可以显示解密的数据?只是为了澄清我知道如何解密值我只需要知道如何将解密的值放入字段中.是否有我可以使用的 change_view 方法的 django 信号?

I have values in a database that are encrypted, how can I override django's admin edit form so that the fields can display the decrypted data? Just to clarify I know how to decrypt the values I just need to know how to get the decrypted values into the fields. Is there a django signal for the change_view method that I could perhaps use?

推荐答案

虽然可以覆盖模型管理员使用的模型表单 (docs),在这种情况下,我会考虑使用 自定义字段类型,并将加密/解密内置到数据库序列化/反序列化中

while it's possible to override the modelform used by your modeladmin (docs), in this case i would consider using a custom field type, and building in the encryption/decryption into the database serialisation/deserialisation

这篇关于覆盖 django-admin 编辑加密数据的表单字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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