On Sat, 2008-11-29 at 03:29 -0800, coan wrote:
> 
> 
> On Nov 29, 2:45 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
> 
> >         user.edition_set.order_by('rating__rating')
> >
> > will do what you want.
> >
> 
> Yes! It does!
> What an amazing timesaver that small line was :-)
> 
> Is it possible to actually access the rating directly from the
> template?
> In the view:
> editions =  user.edition_set.order_by('rating__rating')
> 
> In the template:
> {% for e in editions %}
>     <h1>{{ e.title }}</h1>
>     Your own personal rating: {{ e.rating.rating }} <-- this obviously
> won't work.
> {% endfor %}

The set of associated rating for an entry 'e' are accessible via
e.rating_set. So {{e.rating_set.rating}} will do what you're after. This
is a little bit hidden in the documentation, but it's documented at 

http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects

(and also fairly clearly explained in part 1 of the tutorial).

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
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