changed constrain on model

This commit is contained in:
Thomas Nahuel Rusiecki 2024-12-01 19:46:04 -03:00 committed by Cayo Puigdefabregas
parent 1fc3c07816
commit 5c64c86a57

View file

@ -27,7 +27,9 @@ class StateDefinition(models.Model):
state = models.CharField(max_length=50)
class Meta:
unique_together = ('institution', 'state')
constraints = [
models.UniqueConstraint(fields=['institution', 'state'], name='unique_institution_state')
]
def __str__(self):
return f"{self.institution.name} - {self.state}"