To expand on DR's answer slightly, the '=' in 'filter(crcWaarde=0)' is
not a comparison
operator.  All arguments to filter need to be of the form
"'leagal_identifier'=value".  This
is python syntax, nothing to do with django.  Think of this '=' as
being more akin to
assignment.

The answer to your problem is to use exclude instead of filter:

                ...get_query_set().exclude(ccWaarde=0)

Bill

On Fri, Mar 19, 2010 at 9:35 AM, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Mar 19, 1:22 pm, BobAalsma <b...@leaddevice.com> wrote:
>> In models.py, when I use
>> class GevondenManager(models.Manager):
>>         def get_query_set(self):
>>                 return 
>> super(GevondenManager,self).get_query_set().filter(crcWaarde
>> = 0)
>> I get proper answers.
>>
>> However, I want to filter on "not equal to" and this does not seem to
>> work. How to proceed?
>>
>> I have tried
>> class GevondenManager(models.Manager):
>>         def get_query_set(self):
>>                 return 
>> super(GevondenManager,self).get_query_set().filter(crcWaarde
>> <> 0)
>>
>> as well as
>> class GevondenManager(models.Manager):
>>         def get_query_set(self):
>>                 return 
>> super(GevondenManager,self).get_query_set().filter(crcWaarde !
>> = 0)
>>
>> and in both cases the results seem the same:
> <snip>
>> NameError: global name 'crcWaarde' is not defined
>
> This needs to be a standard filter expression. So you use the normal
> Django query filter syntax as documented here:
> http://docs.djangoproject.com/en/1.1/topics/db/queries/#retrieving-specific-objects-with-filters
>
> Don't forget these are *parameters to a function*, not expressions in
> themselves. So in your case you need:
>  return
> super(GevondenManager,self).get_query_set().exclude(crcWaarde=0)
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to