From 92a17eaae081a213171b044858d6fc29df2df733 Mon Sep 17 00:00:00 2001 From: Marc Tamlyn Date: Thu, 9 Oct 2014 17:04:50 +0100 Subject: Fixed #23627 -- Allowed register_lookup to work as a decorator. --- docs/howto/custom-lookups.txt | 12 ++++++++++++ docs/releases/1.8.txt | 3 +++ 2 files changed, 15 insertions(+) (limited to 'docs') 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` can now be registered using + a decorator pattern. + Signals ^^^^^^^ -- cgit v1.3