更新时间:2023-12-01 13:07:58
在您的admin.py
class ABCAdmin(admin.ModelAdmin):
fields = [.....] # here comes the fields open to all users
def change_view(self, request, object_id, extra_context=None): # override default admin change behaviour
if request.user in gruop2: # an example
self.fields.append('field2') # add field 2 to your `fields`
self.fields.append('field3') # add field 3 to your `fields`
您可以使用文档查看有什么可用的.上面是从我的用法之一中获取的示例.您可能还需要定义change_view
和add_view
.
You can use the docs to see what is available. Above is an example taken from one of my usages. You may also need to define change_view
and add_view
too.