I've done a few configurations (inlines, filters, order_by...) to the Django admin interface but I would like to change the behavior of the save button when you add a new item. Take a look at my interface (It is in French, but it should be easy to understand prix:price - enregistrer:save)
I have three price field, one for the current item price and two other for previous prices. What I want to do is when the current price is changed and saved, the data from price goes to price2 and price2 to price3 automatically. Like that, I always see what the older prices were.
And maybe one more thing : is it possible that when save(enregistrer) is clicked, I can return to a particular page, and not to the list of all objects?
Thanks for helping!
There are several ways to accomplish your requirement. The two most obvious are:
save
method of your model (refer to the Django docs).save_model
method of yourModelAdmin
.I would go for 1. because this looks like logic that you don't want to tie to the admin explicitly, but it depends on the app you are building.
Regarding the redirect, you might want to have a look at Redirect on admin Save.
You can override admin save method like that:
and this question may help you with redirect after save: Redirect on admin Save