0
I need to calculate the average of a school report where the data are filled in in Django Admin, I would like to take each value make the media and play on a table in 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 that has in the Model, but I can not do the average with the notes, could help me?
But the average between which fields?
– Marlysson
Average between MB1 (1st quarter) and MB2 (2nd quarter)
– Gabriel George