On Sat, Dec 27, 2008 at 7:48 AM, eldonp2 <[email protected]> wrote:
>
> Is there a way to calculate and store the average rating in this
> example:

It's not entirely clear which part of this problem you want help with.

 - Computing the average rating. The brute force approach would be to
iterate over the relevant related objects and compute an average. A
smarter approach would be to use SQL to compute the average.

 - Storing the average in the related model. This could be as simple
as saving an instance of the BookRatings model after computing the
average. You could also use signals or save() overriding to automate
the update of the BookRatings model.

 - Model design. It's not entirely clear why you would want to
denormalize the average values, and then put them into a separate
model.

If you provide a better description of the problem you want help with,
what you have already tried, and what problems you have experienced,
we may be able to provide a more meaningful answer to your problem.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to