django
django copied to clipboard
Note that action descriptions are %-formatted.
Description strings are not %-formatted.
I'm quite sure they are https://github.com/django/django/blob/main/django/contrib/admin/options.py#L1029
If I make a description Assign to University %r
I get the following:
For a realistic example, we generate actions based on category names. If a category name is something like Assign to SIOC: % change Matric result improvement
we get the following exception:
I was surprised by the need to escape these, so I figured a note in the docs might help. I couldn't see any documentation that this is actually an intended feature so personally I'd prefer if this didn't do interpolation on my descriptions.
We generate action functions dynamically and assign the description via the short_description attribute.
I'm really surprised, we should document supported placeholders in Admin actions
docs.
@jbothma Do you have time to keep working on this?
Hi! Happy to try! Can't make big promises.
Do you just want something like this?
.. note::
The description string will be %-formatted. Supported values are verbose_name
and verbose_name_plural of the model.
%-signs intended to be printed as-is should be escaped with another %-sign, i.e. as %%.
Hi! Happy to try! Can't make big promises.
Do you just want something like this?
Yes something similar, e.g.
.. admonition:: Description formatting
Action descriptions may contain ``'%(verbose_name)s'`` and
``'%(verbose_name_plural)s'``, which are replaced, respectively, by the ... and ....
Superseded by #16640.