Re: querying for an empty set in m-r?

2006-04-19 Thread akaihola
I vaguely remember an advice to use __isnull in a similar situation. Maybe one of these discussions turns up something useful: http://simon.bofh.ms/logger/django/search/?q=isnull --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: querying for an empty set in m-r?

2006-04-15 Thread Ian Clelland
On 4/12/06, Max Battcher <[EMAIL PROTECTED]> wrote: > Oh, right. You could do: > > tags = [tag for tag in Tag.objects.all() if tag.article_set.count() == 0] > > n queries for n tags, but it is "pretty" Python. Doing db-cleanup > shouldn't happen all that often, so you probably don't need the

Re: querying for an empty set in m-r?

2006-04-12 Thread Brian Elliott
Russell, Just wanted to thank you for responding to my post. You did interpret my question correctly, though I was obviously hoping to avoid using raw SQL. Anyway, thanks again. Brian On Apr 12, 2006, at 1:10 AM, Russell Cloran wrote: > > Hi, > > On Tue, 2006-04-11 at 21:20 -0400, Max

Re: querying for an empty set in m-r?

2006-04-12 Thread Brian Elliott
Max, Just wanted to thank you for responding to my question. You are correct that the list comprehension is pythonic, though I was ideally looking for a efficient method from a database perspective. Thanks, Brian On Apr 12, 2006, at 2:16 AM, Max Battcher wrote: > > Russell Cloran wrote:

Re: querying for an empty set in m-r?

2006-04-12 Thread Max Battcher
Russell Cloran wrote: > Hi, > > On Tue, 2006-04-11 at 21:20 -0400, Max Battcher wrote: >> if sometag.article_set.count() == 0: >> pass # your code here > > This will test if one tag has an empty article_set. AFAICT, the question > is on how to find all tags which have an empty article_set.

Re: querying for an empty set in m-r?

2006-04-11 Thread Max Battcher
if sometag.article_set.count() == 0: pass # your code here On 4/11/06, Brian Elliott <[EMAIL PROTECTED]> wrote: > > Suppose I have the following two model objects: > > class Tag(models.Model): > name = models.CharField(maxlength=10) > > class Article(models.Model): > tags =

querying for an empty set in m-r?

2006-04-11 Thread Brian Elliott
Suppose I have the following two model objects: class Tag(models.Model): name = models.CharField(maxlength=10) class Article(models.Model): tags = models.ManyToManyField(Tag) Each Article can be associated with multiple Tags and vice versa. How can I query the Tag model to