Of course, and thanks for your help :)

This is the rows of my first table Video :
id | name | category_id | date
1 | vids1 | 1 | dd-jj-mmmm
2 | vids2 | 1 | dd-jj-mmmm
3 | vids3 | 1 | dd-jj-mmmm
4 | vids4 | 2 | dd-jj-mmmm
5 | vids5 | 2 | dd-jj-mmmm
6 | vids6 | 3 | dd-jj-mmmm

and here the rows of the category table :
id | name
1 | SF
2 | drama
3 | news

I want to retrieve the latest vod by categories, so that s why i thought
about the group_by category. So with a group_by i should retrieve :
1 | vids1 | 1
4 | vids4 | 2
6 | vids6 | 3
Am i wrong ?

On Fri, Jul 15, 2011 at 2:43 PM, bruno desthuilliers <
bruno.desthuilli...@gmail.com> wrote:

> On Jul 15, 10:13 am, Suprnaturall <n.her...@gmail.com> wrote:
> > 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}
>
>
> Queryset.values(*fieldnames) returns a list of fieldname:value dicts
> (instead of model instances), possibly restricted to specified
> fieldnames.
>
> https://docs.djangoproject.com/en/1.3/ref/models/querysets/#values
>
>
>
> > Do you have any clue ? What is the correct way to make a group by and
> > then retrieve all the data in the table ?
>
> I don't see the point of a group_by here. Would you care to explain
> more exactly what you are trying to achieve (I mean, the desired
> output - not what you think is the solution).
>
>
> --
> 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.
>
>

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