Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Note that action descriptions are %-formatted. #15921

Closed
wants to merge 1 commit into from

Conversation

jbothma
Copy link
Contributor

@jbothma jbothma commented Aug 5, 2022

No description provided.

@felixxm
Copy link
Member

felixxm commented Aug 10, 2022

Description strings are not %-formatted.

@felixxm felixxm closed this Aug 10, 2022
@jbothma
Copy link
Contributor Author

jbothma commented Aug 10, 2022

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:

Screenshot_2022-08-05_14-42-35

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:

Screenshot_2022-08-10_10-33-21

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.

@felixxm
Copy link
Member

felixxm commented Aug 10, 2022

I'm really surprised, we should document supported placeholders in Admin actions docs.

@felixxm felixxm reopened this Aug 10, 2022
@felixxm
Copy link
Member

felixxm commented Feb 23, 2023

@jbothma Do you have time to keep working on this?

@jbothma
Copy link
Contributor Author

jbothma commented Feb 23, 2023

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 %%.

@felixxm
Copy link
Member

felixxm commented Feb 23, 2023

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 ....

@felixxm
Copy link
Member

felixxm commented Mar 9, 2023

Superseded by #16640.

@felixxm felixxm closed this Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants