mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #23627 -- Allowed register_lookup to work as a decorator.
This commit is contained in:
parent
d6a87eefd8
commit
92a17eaae0
5 changed files with 22 additions and 14 deletions
|
@ -46,6 +46,18 @@ it with ``Field`` directly::
|
|||
from django.db.models.fields import Field
|
||||
Field.register_lookup(NotEqual)
|
||||
|
||||
Lookup registration can also be done using a decorator pattern::
|
||||
|
||||
from django.db.models.fields import Field
|
||||
|
||||
@Field.registerLookup
|
||||
class NotEqualLookup(Lookup):
|
||||
# ...
|
||||
|
||||
.. versionchanged:: 1.8
|
||||
|
||||
The ability to use the decorator pattern was added.
|
||||
|
||||
We can now use ``foo__ne`` for any field ``foo``. You will need to ensure that
|
||||
this registration happens before you try to create any querysets using it. You
|
||||
could place the implementation in a ``models.py`` file, or register the lookup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue