So we will have
{{{
SomeModel.register_lookups([L1, L2, L3])
}}}
I think django code will become somewhat clearer.
--
Ticket URL: <https://code.djangoproject.com/ticket/24946>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
If it is good to go, I will implement this
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:1>
* has_patch: 0 => 1
Comment:
Ticket is not accepted/declined yet. but anyway there is a PoC PR -
https://github.com/django/django/pull/4829
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:2>
* status: new => closed
* resolution: => wontfix
Comment:
I'm not convinced we need this. Creating new lookups and transforms should
be somewhat rare, so just writing the couple extra characters to register
the lookup shouldn't be a problem when creating lookups/transforms.
I'm going to close this as wontfix. I don't feel too strongly about this,
so if some other core dev does see this as an useful addition, I'm not
going to object reopening this.
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:3>
Comment (by carljm):
FWIW, I agree that this is not needed.
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:4>
Comment (by coldmind):
> Creating new lookups and transforms should be somewhat rare
Well, will be it rare or not, there will more and more lookups and
transforms, so there will be more similar lines which is not DRY.
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:5>
Comment (by carljm):
Replying to [comment:5 coldmind]:
> > Creating new lookups and transforms should be somewhat rare
> Well, will be it rare or not, there will more and more lookups and
transforms, so there will be more similar lines which is not DRY.
For what it's worth, IMO this is a mis-use of the concept of DRY. DRY
means that each piece of knowledge has one and only one authoritative
representation in the system. That is, it means that any given change to
the system should need to be made in one location, not simultaneously in
multiple different locations.
Registering multiple lookups with successive calls to `register_lookup` is
not a violation of DRY, because each piece of information (the fact that
lookup X is registered with the field, and the fact that lookup Y is
registered with the field, etc.) is captured in exactly one place (the
call to `register_lookup`). If that piece of information changes (lookup Y
should no longer be registered with the field) that change needs to be
made in one and only one place.
"A violation of DRY" is not the same thing as "I had to type more
characters than I would have preferred to type." It's not even the same
thing as "I had to type the same sequence of characters several times."
Conciseness is also of value in API design, but it's not the same issue as
DRY. Its value depends a great deal on frequency of use, and it has to be
weighed against other concerns, such as overall API size, confusing
similarity of one method with another (leading to indecision about which
method is the appropriate one to use), etc.
--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:6>