diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-10-09 17:04:50 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-10-09 18:44:58 +0100 |
| commit | 92a17eaae081a213171b044858d6fc29df2df733 (patch) | |
| tree | eae95057cfb26745d2bd99dba63811aae6d5db8e /docs | |
| parent | d6a87eefd87250e68457488cfd62fb2cc8211b24 (diff) | |
Fixed #23627 -- Allowed register_lookup to work as a decorator.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/howto/custom-lookups.txt | 12 | ||||
| -rw-r--r-- | docs/releases/1.8.txt | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/docs/howto/custom-lookups.txt b/docs/howto/custom-lookups.txt index c02b896071..820a2ef574 100644 --- a/docs/howto/custom-lookups.txt +++ b/docs/howto/custom-lookups.txt @@ -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 diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 0e42f1f12f..631b0bd2f0 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -299,6 +299,9 @@ Models * ``extra(select={...})`` now allows you to escape a literal ``%s`` sequence using ``%%s``. +* :doc:`Custom Lookups</howto/custom-lookups>` can now be registered using + a decorator pattern. + Signals ^^^^^^^ |
