Reputation: 706
For all of my Django needs that overriding the save method requires, I've been using save()
in my models. All the sudden when I was looking up something that required a little extra flare, someone suggested overriding save_model()
in my admin class.
I found the docs on both, and I noticed right away that the arguments are different.
Is save_model()
only called when the model is saved from the admin? and the save()
method is called whenever the model is saved?
UPDATE
So I've figured out that when saving from the admin. Both 'save' and 'save_model()' get called. It appears that 'save_model()' gets called first. In my specific application, I am using pre_save signals, and 'save()' overrides. Now I want to add in 'save_model()'overrides . It's the interaction and order of all of these save overrides and signals that is confusing me.
Upvotes: 14
Views: 4226
Reputation: 798746
As save()
is a method of Model
whereas save_model()
is a method of ModelAdmin
... yes.
Upvotes: 5