changed constrain on model

This commit is contained in:
Thomas Nahuel Rusiecki 2024-12-01 19:46:04 -03:00
parent 22d4cea560
commit 175b6d93dc

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}"