I have the model
class Owner(models.Model):
name = models.CharField(max_length=10)
class PhoneNumber(models.Model):
isActive = model.BooleanField(default=False)
owner = model.ForeignKey('Owner')
I want to enforce that only one PhoneNumber is active so if the user, when creating or editing a 'not active' PhoneNumber, accidentally sets it to 'active' and there is another 'active' PhoneNumber already the form should not submit and a clear error will get displayed to change the 'active' field to False and error text "Please deactivate the old active PhoneNumber before assigning a new active PhoneNumber"
How do I do this? In which validation method in which class do I check this easily ?
Thank you