简体   繁体   English

使用DB中的数据填充字段以在django-admin上进行验证

[英]Fill field with data from DB for validation on django-admin

I'm working with django and it's powerful administrator. 我正在使用django,它是功能强大的管理员。

It's simple. 这很简单。 I have a field that needs to be filled with the contents of database for validation. 我有一个字段需要填写数据库的内容以进行验证。

Example: The field is Name. 示例:字段为名称。 I want the field to make itself a deployable list with all the names contained in the DB. 我希望该字段使自己成为具有DB中包含的所有名称的可部署列表。

If the field is Name, the user should see a deployable list with "John", "Edward", "Joshua"... Because those have been stored in the db. 如果该字段是Name,则用户应该看到带有“ John”,“ Edward”,“ Joshua” ...的可部署列表。因为这些已存储在数据库中。

It can be easily done with a ChoiceField, give it a try and if you cannot solve it I will gadly help you. 可以使用ChoiceField轻松完成,尝试一下,如果您不能解决,我将竭诚为您服务。

https://docs.djangoproject.com/en/2.2/ref/forms/fields/#choicefield https://docs.djangoproject.com/zh-CN/2.2/ref/forms/fields/#choicefield

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

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