Re: category counter

2008-01-25 Thread Chris
Cool. I tried that early and it didn't work. I just tried it again and it seems to work. must of keyed something in wrong. >>> Weblog.objects.filter(category__id='1').count() 3L Thanks for your help. On Jan 25, 2:08 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > On Jan 25, 2:01 pm, Chris <[EMA

Re: category counter

2008-01-25 Thread Rajesh Dhawan
On Jan 25, 2:01 pm, Chris <[EMAIL PROTECTED]> wrote: > Cool here is my models and I posted an sql query to: > > Modelshttp://dpaste.com/32548/ > > SQL Queries (posted a question in this one)http://dpaste.com/32552/ > > Hope this helps. maybe there is a better way of doing what I am trying > to d

Re: category counter

2008-01-25 Thread Chris
Cool here is my models and I posted an sql query to: Models http://dpaste.com/32548/ SQL Queries (posted a question in this one) http://dpaste.com/32552/ Hope this helps. maybe there is a better way of doing what I am trying to do. Thanks for helping. On Jan 25, 12:59 pm, Rajesh Dhawan <[EMA

Re: category counter

2008-01-25 Thread Rajesh Dhawan
On Jan 25, 12:42 pm, Chris <[EMAIL PROTECTED]> wrote: > Thanks for reply but that is not what I am looking to do. my [EMAIL > PROTECTED] table > is NOT the categories table. Well, as I said in my earlier post, you still haven't posted your model code. It would help people understand better wha

Re: category counter

2008-01-25 Thread Chris
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-- >ca

Re: category counter

2008-01-25 Thread Rajesh Dhawan
>  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 e

Re: category counter

2008-01-25 Thread Chris
Thanks for the response. If only it were that easy :). In my categories table, each category should be unique. What I am trying to count is the m2m ref table. Example. category_id | name 1 | programming 2 | politics 3 | games blog_id | category_id 1 | 2 <-- I am trying to reference this table

Re: category counter

2008-01-25 Thread Thomas Guettler
Hi, There are two ways of counting: # Bad way: len(MyModel.objects.filter(...)) This will fetch all rows (SELECT * FROM ... WHERE ...;) # Good way: MyModel.objects.filter(...).count() This will do the couting at the database SELECT COUNT(*) FROM ... WHERE ...; If you know how to get all

category counter

2008-01-24 Thread Chris
hello again. thanks for all the help that everyone has offered me here. I have a generic django application called categories and it serves to provide categories for various apps suchas a weblog or an articles application. So a weblog and article app both have a M2M relation to the catergories ap