Making inlines conditional in the Django admin

后端 未结 8 2456
长发绾君心
长发绾君心 2021-02-07 21:45

I have a model that I want staff to be able to edit up to the date for the event. Like this:

class ThingAdmin(admin.ModelAdmin):
    model = Thing

    if obj.da         


        
8条回答
  •  天命终不由人
    2021-02-07 22:34

    I think the best answer is in the django documentation: https://docs.djangoproject.com/en/1.9/ref/contrib/admin/

    Search for "get_inline_instances" The example provided is very good and the nuances of the call are described in detail.

提交回复
热议问题