However this particular usage is not documented (take the example of the
various `truncate*` filters [1]).
I think it would be useful to know:
1) Which template filters can be used as functions;
2) Where to import them from and how to use them;
3) If there are limitations/gotchas related to using them.
[1]
https://docs.djangoproject.com/en/1.10/ref/templates/builtins/#truncatechars
--
Ticket URL: <https://code.djangoproject.com/ticket/27106>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
While I think I've imported from `django.template.defaultfilters` in some
of my own projects, I'm not sure that promoting that pattern as a public
API is a good idea. Some of the filters use functions from
`django.utils.*`, e.g. the `slugify` filter uses
`django.utils.text.slugify`. I don't mind linking to those utility
functions from the template tag documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:1>
Comment (by aaugustin):
Yes, generally speaking Django template filters should be thin wrappers
about utility functions. This makes it easy to use the underlying plain
function in Jinja2 templates.
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:2>
* owner: nobody => Burhan Khalid
* status: new => assigned
Comment:
I'll work a PR for this, where I'll link to the relevant `django.utils.*`
documentation for those filters that are pure wrappers for other
functions.
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:3>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/7519
There was some documentation missing for some of the utils functions,
which I added to the relevant sections in order to ensure Sphinx internal
references were linked correctly.
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:4>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:5>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:6>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:7>
* owner: Burhan Khalid => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/27106#comment:8>