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
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
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
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:
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.
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 =
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
7 matches
Mail list logo