Thanks for reply but that is not what I am looking to do. my [EMAIL PROTECTED] 
table
is NOT the categories table. In django, when it generates your models,
it automatically generates your M2M table reference. so I have a table
called blog that has a m2m relation with categories. (blog-->M2M--
>categories) Right! Ok so using distinct on the category table would
NOT work since they would already be distinct. The table that I need
to grab results from is the M2M table NOT categories.  Make sense?

On Jan 25, 12:03 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> >  so if category_id 2 name is 'politics' it would know that it occurs 3
> > times. make sense?  The easy way would be to create a counter field in
> > the categories table and count each time that the category is being
> > used but that is redundant and require extra work to save the category
> > count each time I add a new entry.  The answer is already there I just
> > need to figure out how to retrieve that answer. :)
>
> You didn't include your full model, but have you tried something like
> this?
>
> Blog.objects.filter(categories__name='politics').distinct().count()
>
> This assumes that Blog.categories is your M2M field.
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to