Reputation: 5231
I've got several ModelAdmin classes and I'd like to do the same action when save the model so I created mixin object for this purpose:
class SaveModelMixin(object):
def save_model(self, request, obj, form, change):
if obj.is_executed and 'is_executed' in obj.changed_data:
obj.date_execution = datetime.date.today()
super(self.__class__, self).save_model(request, obj, form, change)
And when I try to save object in admin, this method just runs itself again and again, and I can't figure out why.
Upvotes: 1
Views: 1112
Reputation: 474041
Looks like your super()
call is incorrect, try this:
super(SaveModelMixin, self).save_model(request, obj, form, change)
See explanation here: How to avoid infinite recursion with super()?
Also see:
Upvotes: 3