Say you have the following model:
class Student(models.Model):
student_no = models.IntegerField(primary_key=True)
GPA = models.DecimalField(max_digits=65535, decimal_places=65535)
year_of = days_on_market = models.IntegerField()
and you want to associate the highest GPA with ALL students. How do you go about doing that? I have tried the following:
Student.objects.annotate(max_GPA = Max('GPA')).aggregate(Max('GPA'))
As per the documentation. But, this does not associate the max GPA with each student. It only associate the max GPA for a record which is the same as the GPA of that record with the record, which is as useless as it gets. It also returns a dictionary {'GPA__max': 4.3}, but that is not the intention of the code.
I have looked here, but, this solution does the same thing as the other one, namely associating the max GPA of the record (and not max GPA of all records), which is the same as the GPA anyway.
In effect, I want that 4.3 to be associated with every student.
Any creative solution?