开发者

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


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.


http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_model

describes the function you're talking about. My best guess is that you're confused about when and where that will be called. Also, are you sure you're actually working with the latest revision?

Edit: I'd guess that inline ModelAdmin objects may behave differently, given their otherwise special status.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜