reverse() shouldn't require kwargs for uniquely determined named groups
|Reported by:||Chris Jerdonek||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
For DRY purposes, it can be useful to capture a known substring in an URL for access from a view. For example--
url(r'^(?P<action>create)/confirm/$', ConfirmCreateView.as_view(), name='confirm_create') url(r'^(?P<action>change)/confirm/$', ConfirmChangeView.as_view(), name='confirm_change')
reverse() for examples like the above still requires passing the keyword argument though (
action='change' in these examples), even though the value of the keyword argument isn't necessary to construct the corresponding URL. This makes calling
reverse() less DRY than it needs to be.
I would like to suggest making
reverse() not require the keyword arguments in cases where the corresponding named groups have only one possible value. If this isn't possible to add, are there any suggestions for a DRY way to accomplish the same thing?
Change History (4)
comment:1 Changed 3 years ago by
|Patch needs improvement:||unset|