On Thu, 2006-06-22 at 15:48 +0000, [EMAIL PROTECTED] wrote: > I have found that, in some cases, the following also works (I have a > similar model where using the slug of the related object does not work > but using it's PK works): > > tag_id = Tag.objects.get(tag = 'nopush').id > x = Server.objects.exclude(tags__id__exact=tag_id)
You said "in some cases", which is important. This won't return the correct results for an object that has, say, both the "nopush" and "nopull" tags on it. That object will have two entries in the m2m table and the entry for the "nopush" tag will be excluded, whereas the other entry will be selected. It will work if the tag you are trying to exclude by is always the *only* tag on a server. I think you (Rajesh) realise this, since you did qualify your claim. But I wanted to point it out for when people find this in the archives. I am truly not intending to demean your observation. > If you are in DEBUG mode, you can also print out your SQL queries in > your HTML page footer to see how Django is constructing the SQL for > your QuerySet. Particularly for the "why doesn't this work" cases, this is usually a lifesaver. Regards, Malcolm > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---

