Thank you karen. It works.

cschand


On Feb 20, 7:04 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Wed, Feb 20, 2008 at 8:32 AM, [EMAIL PROTECTED] <
>
> [EMAIL PROTECTED]> wrote:
>
> > Sounds like you want a QNot, they work like Q:
>
> >http://www.djangoproject.com/documentation/db-api/#complex-lookups-wi...
> > except it inverts the argument.
>
> > On Feb 20, 6:45 am, cschand <[EMAIL PROTECTED]> wrote:
> > > No I want
> > >   exclude(access_type=2, and owner_name<>'name')
>
> from django.db.models import Q
> from django.db.models.query import QNot
>
> then
>
> exclude(Q(access_type=2) & QNot(Q(owner_name='name')))
>
> will exclude networks with access_type 2 excepting those owned by
> 'name'....that is, networks with access_type 2 owned by 'name' will still be
> included in the result set.
>
> Not sure how future-proof that is since I can't find QNot documented.  But I
> don't see an easier way to do it since there's no "not equal" lookup; as I
> understand it there used to be one but it was removed when exclude() was
> introduced since exclude() does what "not equal" was used for.  Except when
> you want to put a not equal lookup in your exclude list...but I'll admit to
> feeling a bit dense this AM so perhaps I am missing something.
>
> Karen
>
>
>
>
>
> > > On Feb 20, 5:36 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
> > > > On Wed, Feb 20, 2008 at 4:59 AM, cschand <[EMAIL PROTECTED]> wrote:
>
> > > > > Hi all,
>
> > > > >  I have a Model Manager class
>
> > > > > class NetworkManager(models.Manager):
>
> > > > >    #filtering private networks
> > > > >    def get_query_set(self):
> > > > >        return super(NetworkManager,
> > > > > self).get_query_set().exclude(access_type=2)
>
> > > > > I excluded access_type 2 from this set. But i need to include (or
> > > > > append) the following condition
>
> > > > > access_type=2 and owner_name='name'
>
> > > > > Can you help for including or appending with the queryset
>
> > > > Exclude is described here:
>
> > > >http://www.djangoproject.com/documentation/db-api/#exclude-kwargs
>
> > > > to AND together all of its parameters and enclose them in a NOT, so
> > assuming
> > > > you want to exclude only those networks with  access_type 2 and
> > owner_name
> > > > 'name', change your exclude to:
>
> > > > exclude(access_type=2,owner_name='name')
>
> > > > If that's not what you want please describe more explicitly what it is
> > you
> > > > want to exclude since it isn't entirely clear to me from your first
> > note.
>
> > > > Karen- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
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