I need to calculate the age of a school report card where the data is filled in Django Admin, I would like to get each value to media and play in a table in the View.
Code:
MODEL
class Cadastro_Boletim(models.Model):
ra_aluno = models.ForeignKey(Aluno, models.DO_NOTHING, related_name='Nome')
curso = models.ForeignKey(Curso, models.DO_NOTHING, db_column='Curso') # Field name made lowercase.
nome_disciplina = models.ForeignKey(Disciplina, models.DO_NOTHING, db_column='Nome_Discplina')
MB1 = models.SmallIntegerField(blank=True, null=True) # Field name made lowercase.
SUB1 = models.SmallIntegerField(blank=True, null=True)
MB2 = models.SmallIntegerField(blank=True, null=True)
SUB2 = models.SmallIntegerField(blank=True, null=True)
EX = models.SmallIntegerField(blank=True, null=True)
regular = models.BooleanField("Ativo?",default=True)
VIEW
def boletim(request):
contexto = {
'boletim': Cadastro_Boletim.objects.all()
}
return render(request,"boletim.html", contexto)
That way it brings everything you have in the Model, but I can not average the grades, could you help me?