Hi dear django users :)

I m facing a stupid problem.
Here is my models.py :

class Video(models.Model):
    (...)
    category = models.ForeignKey('Category')
   (...)

class Category(models.Model):
    name = models.CharField(max_length=250)

I'm trying in a tags to make a group by on the category field and
retrieve in the template the name of the first vid and its category
name.

Here it s my teamplate.py :

@register.inclusion_tag('appFront/home_tag.html')
def home_vods():
        videos =
Video.objects.values('category').annotate(dcount=Count('category'))
        return {'videos': videos}

And here it s the template.html

<div class="home_tag">
        {% for video in videos %}
                        <a href="">{{ video.title }}</a>{{ video.title }}|
{{ video.category.name }}<br />
        {% endfor %}
</div>

I retrieve the correct number of row (in my case 3) but it s seems
that the query set is empty because it may invoque this query " SELECT
category FROM video group by category ", so i retrieve the correct
amount of row but the only field populate is category, on the other
hand i don t retrieve in my .html the date video.category.name, i got
nothing oO

Do you have any clue ? What is the correct way to make a group by and
then retrieve all the data in the table ?

Thx for your help :)

-- 
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 more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to