My Models
class Student(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
classroom = models.ForeignKey(‘Classroom’,
on_delete=models.DO_NOTHING,blank=True, null=True)
class Classroom(models.Model):
name = models.CharField(max_length=40,blank=True, null=True)
class Fee(models.Model):
student = models.ForeignKey(Student, on_delete=models.CASCADE, null=True,)
classroom = models.ForeignKey(Classroom, on_delete=models.CASCADE,
null=True)
school_fees = models.FloatField(default=1000000)
paid_fees = models.FloatField(null=False)
remaining_fees = models.FloatField(blank=True)
completed = models.BooleanField(null=False, default=False)
views.py
def student(request, pk):
student = Student.objects.get(id=pk)
fees = student.fee_set.all().order_by('-publish_date') total_fees =
student.fee_set.all().filter(student__id=pk)
.aggregate(sum=Sum('paid_fees', flat=True)['sum']
fees_remaining = ()
return render(request, 'website/students.html', context)
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/6c03e499-43b8-487f-851b-a7742bb89fb7n%40googlegroups.com.