Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 Django admin 中为添加新项目和查看项目创建不同的视图。例如,我为添加项目制作了新表单,但现在当我打开编辑视图时,我需要模型中的基本表单。
对的,这是可能的。像这样做:
class MyModelAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): if not obj: return MyModelCreateForm return super(MyModelAdmin, self).get_form(request, obj, **kwargs)