【发布时间】:2014-09-05 08:13:16
【问题描述】:
我在管理中显示了一个简单的模型。在添加视图中,我有 4 个字段,第一个字段是用户的外键。我需要:
- 预填充用户字段。
- 将该字段设为只读。
我找不到任何关于此的文档。我查看了以下链接:
- django admin "add page" initial datetime from GET parameters,
- Customize Django Admin: Add More Than One Default Inline on Parent Add_View
编辑: 我在这里找到了第一个问题的解决方案; Djanjo admin: Prefill data when clicking the add-another button next to a ForeignKey dropdown
【问题讨论】:
-
您希望用户字段预填充当前用户(即添加对象的人)吗?
-
不,我希望用绑定到该对象的用户填充该字段。管理员将添加对象。
-
已经解决了。从添加视图中将字段设为只读是我遇到的问题。
标签: python django django-admin