Re: How to cache model field?

2011-05-10 Thread Amanjeev Sethi
You can have a field called "total_votes" in the Book model. Then you can override the save() method in the Vote class, which calculates the total votes on a particular Book and updates the "total_votes" in the book. Also, why not use https://github.com/brosner/django-voting Django-voting app? I

Re: How to cache model field?

2011-05-10 Thread Amanjeev Sethi
oops. my bad wrong email. sorry. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For mo

How to cache model field?

2011-05-10 Thread Eugene Goldberg
For example, we have object 'book' and 'vote'. Each vote is assigned to some book. On page I'd like to know how many votes was for certain book? The first solution was to create a methdon in book model: def get_votes(self): .. database query here . return an integer... That is the best w