2
I’m still a beginner in Django
and would like to know how I would do to save a certain amount of students in vacancies.
Example: vagas = 5
, how do I allow them only to be saved 5 students?
class Turma(models.Model):
descricao = models.CharField(max_length=50)
vagas = models.PositiveIntegerField()
horario = models.CharField(max_length=5,choices=HORARIO_CHOICES,null=False,blank=False,verbose_name='Turno')
ano = models.PositiveIntegerField(null=False,blank=False)
semestre = models.CharField(max_length=1,choices=SEMESTRE_CHOICES,null=False,blank=False)
aluno = models.ManyToManyField(Aluno,verbose_name='Aluno')
professor = models.ForeignKey(Professor,verbose_name='Professor')
def __str__(self):
return str(self.descricao)