chrisk wrote:

>class Post(models.Model):
>...
>   assoc_cats = models.ManyToManyField(Category)
>...
>
>In my template {% for post in latest %}... works fine, but if i try to
>use the Many-to-many related lookup {{ post.assoc_cats.all }} i get an
>empty list.
>  
>
I wast about to answer something similar to Jay Parlar bu took a minute 
to check it.. And to my own wonder such construction really tries to 
output a list while I thought it should output something like 
<django.db.models.query.QuerySet ... > that is swallowed by HTML as an 
unknown tag.

However this list cosists of repr() of its values. So if you have a list 
with only one value and your assoc_cats don't have __repr__ you will get 
this: "[ ]"

So to have a real list of strings you should either cycle through the 
queryset or just join it:

    {{ post.assoc_cats.all|join:", " }}

It woul work if your assoc_cats do have __str__ method.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to