是否有办法检测模型中的信息是否正在添加或更改.
If there a way to detect if information in a model is being added or changed.
如果有这个信息可以用来排除字段.
If there is can this information be used to exclude fields.
一些伪代码来说明我在说什么.
Some pseudocode to illustrate what I'm talking about.
class SubSectionAdmin(admin.ModelAdmin):
if something.change_or_add = 'change':
exclude = ('field',)
...
谢谢
class SubSectionAdmin(admin.ModelAdmin):
# ...
def change_view(self, request, object_id, extra_context=None):
self.exclude = ('field', )
return super(SubSectionAdmin, self).change_view(request, object_id, extra_context)
这篇关于Django 管理员:仅在更改表单上排除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!