On Thu, 2008-02-21 at 17:17 -0600, Brett Hoerner wrote:
> On Thu, Feb 21, 2008 at 5:06 PM, Albert Hopkins <[EMAIL PROTECTED]> wrote:
> >  I have a model with a M2M field and I want to filter based on the field
> >  being empty.  How do I do this?  I tried
> >  MyModel.objects.filter(m2mfield=[]) but that raises a (MySQL) exception.
> 
> Is this what you want?
> 
> MyModel.objects.filter(m2mfield__pk__isnull=True)
> 

Well that certainly gives me the correct results, but doesn't seem
obvious (or Pythonic) at all :(



--~--~---------~--~----~------------~-------~--~----~
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