models.py 448 B

123456789101112131415
  1. from django.db import models
  2. class Config(models.Model):
  3. indice = models.CharField(max_length=32,null=False)
  4. valore = models.CharField(max_length=128,null=True)
  5. nota = models.CharField(max_length=256,null=True)
  6. def __str__(self):
  7. return f"{self.id}: {self.nome}"
  8. class Meta:
  9. constraints = [ models.UniqueConstraint(fields=['indice'], name="unique-indice") ]
  10. indexes = [ models.Index(fields=['indice']) ]