I'm still a beginner on Django
and would like to know how I would save a certain amount of students on jobs.
Example: vagas = 5
, how do I allow only 5 students to be saved?
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)