0
I’m developing an application in Django that has two models, Modality and Bidding. The Bidding has a FK field (models.Foreingkey), which pulls the Modality. I would like this field to generate an automatic, increasing value (001,002,003) for each Modality.
In this way, to: the mode XXX I can have bidding 001,002,003 .... 999 The YYY mode I can have tender 001,002,003 .... 999
And so on, but in every mode this numbering does not repeat itself.
The code is more or less this:
class Modalidade(models.Model):
modalidade = models.CharField(max_length=20)
class Licitacao(models.Model):
modalidade = models.ForeignKey(Modalidade, on_delete=models.CASCADE)
licitacao = models.CharField(max_length=5)
objeto = models.CharField(max_length=50)
...
This code is implemented in function form in Models, or in Forms?
– Thaís Barras