I have this model
class Inscription(models.Model):
person = models.ForeignKey(Person)
congress = models.ForeignKey(Congress)
folio = models.IntegerField(max_length=4, editable=False)
I need the folio attribute to be unique within the same congress, but repeatable in the table, but it's important that generated random numbers are not repeated (instead of validating if it already exists and then generate a new one).
Is there any way to achieve this? It doesnt matter if the work is to be done in Django or PostgreSQL
Thank you for reading.