Opened 11 years ago
Last modified 5 years ago
#23572 closed Bug
Exception on Custom Lookups when right value is None. — at Initial Version
| Reported by: | maherma-adg | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 1.7 |
| Severity: | Normal | Keywords: | custom lookup, db |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
For my current project I need generate a complex queryset filter and I decide implement as custom lookup.
I got the 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.