Hi, I have been spending some time learning and investigating the custom lookups feature that was newly introduced in 1.7 [0]. While investigating, I wanted to learn by example so I started looking through the Django code. In the end, I didn't find many examples. However, I did notice that there exists lookups for the year, month, day, (and more) value from a database date or datetime value [1]. These appear to be implemented as special case "builtin" lookups and not through the new lookup mechanism. Is there a specific reason for this or is it historical momentum?
I started investigating if these could be refactored to use the common code path and implemented using the new lookup mechanism. To my delight it was not very difficult and I now have all tests passing after refactoring these lookups. Right now, this lives in a branch of mine and not in a ticket or pull request. The WIP branch is located at: <https://github.com/jdufresne/django/tree/date-register-lookup> Would this be something welcome as a ticket and pull request? While there is no outward change in functionality, I see it as a beneficial refactoring because with this change: 1. The year, month, day, etc lookups are no longer treated as special cases, but instead use the common code path. 2. There now exists complete and useful examples of registering new lookups in the Django code itself. This might help others build more lookups. 3. The lookups are now limited to the correct Field types where as previously this was not true. I demonstrate this with a unit test. If this looks like it could be a welcome change I will can go forward with a typical ticket and pull request. Cheers, Jon [0] https://docs.djangoproject.com/en/dev/howto/custom-lookups/ [1] https://docs.djangoproject.com/en/dev/ref/models/querysets/#year -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CADhq2b4C4y5ZUHvNEugizHrqjL4EWoQJQcc8nne%2BjxsmU-L3uA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.