Hi,
I have a  templatetag that returns a lists of objects. The problem is I
want to include another information for every object: I want to include
the number of related objects for every object of a ManyToMany
relationship. The model ArtistaTag has a ManyToMany relationship with
Artistas. So I use:

tags=['']
nums=['']
q = ArtistaTag.objects.all()

for tag in q:
            num = tag.artista_set.count()
            if num >= 1:
                tags.append(tag)
                nums.append(num)
context['lista_tags'] = tags
context['nums'] = nums
return ''

So that I become 2 lists, one with the objects (tags) and the other
with the number of related objects (nums) but I don't know if this is
the right way to do that an more important: I don't know how to get the
number of every object in each object iteration in my template:

{% for tag in lista_tags %}
    {{ tag.name }}
    how to get the num for this tag?

I don't know if you understand me, please send any comments and I will
try to clarify my problem.

Thank you!!!


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