Django: When to customize save vs using post-save signal

I generally use this rule of thumb:

  • If you have to modify data so that the save won’t fail, then override save() (you don’t really have another option). For example, in an app I’m working on, I have a model with a text field that has a list of choices. This interfaces with old code, and replaces an older model that had a similar text field, but with a different list of choices. The old code sometimes passes my model a choice from the older model, but there’s a 1:1 mapping between choices, so in such a case I can modify the choice to the new one. Makes sense to do this in save().
  • Otherwise, if the save can proceed without intervention, I generally use a post-save signal.

Leave a Comment