#23572: Exception on Custom Lookups when right value is None.
-------------------------------------+-------------------------------------
     Reporter:  maherma-adg          |                    Owner:
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  custom lookup, db    |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by timgraham:

Old description:

> For my current project I need generate a complex queryset filter and I
> decide implement as custom lookup.
>
> I got the [https://docs.djangoproject.com/en/1.7/howto/custom-lookups/,
> example] as base to create custom lookup, but during test, this
> expresion:
>
> data = Rsce.filter(duration{{{__}}}ne = None)
>
> throw an exception. Any other expresion run smoothly.
>
> Looking into code exception are thrown in this piece of code:
>

>         if value is None:
>             if lookups[-1] not in ('exact', 'iexact'):
>                 raise ValueError("Cannot use None as a query value")
>
> IMHO the check in lookups must be avoided on custom lookups, allowing
> them to manage None values by themselves.

New description:

 For my current project I need generate a complex queryset filter and I
 decide implement as custom lookup.

 I got the [https://docs.djangoproject.com/en/1.7/howto/custom-lookups/,
 example] as base to create custom lookup, but during test, this
 expression:

 `data = Rsce.filter(duration__ne = None)`

 throws an exception. Any other expression runs smoothly.

 Looking into code exception are thrown in this piece of code:
 {{{
         if value is None:
             if lookups[-1] not in ('exact', 'iexact'):
                 raise ValueError("Cannot use None as a query value")
 }}}
 IMHO the check in lookups must be avoided on custom lookups, allowing them
 to manage None values by themselves.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/23572#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.b1cb6a013d206810d47c8d63be205ffb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to