[Answer]-Limit inlines to edit mode in Django's ModelAdmin

1👍

Try this

class PageAdmin(admin.ModelAdmin):
    form = PageModelForm
    inlines = [FileInLine]

    def get_formsets_with_inlines(self, request, obj=None):
        for inline in self.get_inline_instances(request, obj):
            if isinstance(inline, FileInLine) and obj is None:
                continue
            yield inline.get_formset(request, obj), inline

https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_formsets_with_inlines

👤Kedar

Leave a comment