An alternative is to define a `.get_absolute_url()` method on a model
object, and then use it in the template as `{{
model_object.get_absolute_url() }}`. If a model object however has no
`get_absolute_url` method, it will return an empty href, not an error.
We can combine the two and check if the first parameter has a
`get_absolute_url` method, if that is the case, we return the result of
`get_absolute_url` instead.
--
Ticket URL: <https://code.djangoproject.com/ticket/34261>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* type: Uncategorized => New feature
* resolution: => wontfix
Comment:
Thanks for this ticket, however, IMO this syntax would be really confusing
for users as it mixes URL resolvers and model methods. It would also
unnecessarily complicate an existing Django code.
Please first start a discussion on the DevelopersMailingList, where you'll
reach a wider audience and see what other think, and
[https://docs.djangoproject.com/en/stable/internals/contributing/bugs-and-
features/#requesting-features follow the guidelines with regards to
requesting features].
--
Ticket URL: <https://code.djangoproject.com/ticket/34261#comment:1>
Comment (by Willem Van Onsem):
Well the confusion started for me... when `redirect` accepts a model
object, and `{% url ... %}` does not... :P
--
Ticket URL: <https://code.djangoproject.com/ticket/34261#comment:2>