On May 25, 9:52 am, Pirate Pete <peters.stay...@gmail.com> wrote: > Thank you very very much for your reply. > > There is still a few things i need to grasp. > > Firstly, why did you do this : > annotate(rating_count=Count('rating')).annotate(rating_avg=Avg('rating__rat > ing')) > as opposed to annotate(rating_count=Count('rating'), > rating_avg=Avg('rating__rating'))
No reason, these are equivalent. > Secondly, why is the average rating__rating and the count is only > rating ? Because you're counting the individual rating objects, but you're averaging the values of the 'rating' field on each rating object. > Unfortunately the code you provided doesn't seem to be working however > that could just be my own ignorance at work. > > Does this annotation need to be assigned to some sort of variable and > passed into the render or just run like you stated above? Yes, sorry, assign it to the 'videos' variable and pass it straight into the template context - you can delete the rest of the view code. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.