I have a Django model, that is incredibly simple:
class Person(models.Model):
name = models.CharField(max_length=100)
I want to deny saving of this model if the actual name changes, but I want to allow changes to capitalisation. So for example:
SAM -> sAm: allowed
Sam -> SAM: allowed
Sam -> John: not allowed
How can I override the save()
method of my Person model so that such edits are denied? Particularly, I'm struggling with:
- Gaining access the pre-save version of the object in the
save()
method. - Showing a message to the user within Django's admin area when a save is denied.
- Returning a user back to the edit screen when a save is denied.
Feel free to answer any part of the question on its own, and thanks in advance!