且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

django模型的外部动态内联默认值

更新时间:2023-01-30 10:28:32

Q1:
我的猜测是编辑内联模板,隐藏代理列,并将其默认设置为登录用户。
Q2:
GET参数默认情况下传递给表单。
如果您想使某些字段不可编辑,我认为您需要更改模板以检查这些参数是否存在,然后隐藏(或不隐藏)这些字段。或者,您可以将不同的形式传递给ModelAdmin视图(同样在检查是否存在GET选项之后)。

Q1: My guess would be to edit the inline template, hide the Agent column and set it by default to the logged in user. Q2: GET arguments are passed to the form by default. If you want to make some fields not non-editable I think you need to alter the template to check for presence of those arguments and then hide the fields (or not). Alternatively you could pass different form to the ModelAdmin view (also after checking for the presence of GET options).

Tomus