Search code examples
djangodjango-adminmodeladmin

Override of ModelAdmin.save_model not being called


I'm using the GenerickStackedInline which is a subclass of InlineModelAdmin which goes to ModelAdmin. When I override save_model method... it's not being called.

class LocatedItemStackedInline(generic.GenericStackedInline):
    template = "admin/location_app/located_items/stacked.html"
    model = LocatedItem
    extra = 1
    form = MyModelForm
    raw_id_fields = ('location',)

    def save_model(self, request, obj, form, change):
        import ipdb;ipdb.set_trace()
        super(LocatedItemStackedInline, self).save_model(request, obj, form, change)

    def save_form(self, request, form, change):
        import ipdb;ipdb.set_trace()
        super(LocatedItemStackedInline, self).save_form(request, form, change)

So, I'm missing something?

Any clue?

Regards


Solution

  • The problem was that I was overriding the save_model method on the InlineAdmin instead of on the ModelAdmin itself.

    Now is being called...

    Cheers.