On Jun 15, 12:50 pm, "Nicholas Ding" <[EMAIL PROTECTED]> wrote:
> but I wanna 'where column1 <> %s and column2 <> %s'
> If I were using exclude, the SQL must be 'where not (column1 = %s and
> column2 = %s), that's different.

http://www.djangoproject.com/documentation/db-api/#complex-lookups-with-q-objects

Not sure if there's a neater way to do this, but:

q = QNot(Q(bar='something')) & QNot(Q(bar='something-else'))

Foo.objects.filter(q)

should do something like:
(NOT (foo = %s)) AND (NOT (foo = %s))


> On 6/15/07, Todd O'Bryan <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > Django uses different functions for this. To get the opposite of this
> > (the ne version)
>
> > Foo.objects.filter(bar__exact='something')
>
> > do
>
> > Foo.objects.exclude(bar__exact='something')
>
> > HTH,
> > Todd
>
> > On Fri, 2007-06-15 at 11:37 +0800, Nicholas Ding wrote:
> > > I found Django can not do '<>' operation in SQL, such as "where column
> > > <> %s".
> > > While diving into the source code, it seems easy to add a 'ne' to
> > > existing query terms.
> > > But why Django doesn't include this, it's confuse me a lot.
>
> > > Best Regards.
> > > --
> > > Nicholas @ Nirvana Studio
> > >http://www.nirvanastudio.org
>
> --
> Nicholas @ Nirvana Studiohttp://www.nirvanastudio.org


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