Django Admin: How do I know when a user is editing an existing object or saving a new object?
I would like to learn how to work with Django admin. How do I know when a user is editing an existing object or saving a new object?
For example, if I want a function to do something different when the user saves a new object or saves an edited object, how do I know what it is?
Thanks guys:)
Sorry for my English.
+2
source to share
2 answers
Perhaps you could do one of the following:
- Listening for Django signals. Pre_save signal might be helpful in your case .
- Overwriting ModelAdmin.save_model
- Rewriting your models retains the method described by Adam
+1
Christoph
source
to share