Commit 2d388f3
fix(api): interpolate %(verbose_name_plural)s in action labels (#204)
Django's built-in `delete_selected` (and any action whose
`short_description` uses the admin's `%(verbose_name)s` /
`%(verbose_name_plural)s` placeholders) ships a *format string* that
Django interpolates at render time via `model_format_dict(opts)`. The
SPA's `actions_payload` surfaced it raw, so the Actions dropdown showed
"Delete selected %(verbose_name_plural)s" instead of "Delete selected
files".
`actions_payload` now runs the label through `raw_label % fmt` where
`fmt = model_format_dict(model._meta)`, with a try/except that surfaces
the label verbatim for non-format strings / unknown keys (never 500s).
Test: `test_delete_selected_label_is_interpolated` — the delete_selected
label contains no `%(` placeholder and includes the model plural.
Repo-owner report ("what is verbose names?" — the raw placeholder leaked
to the UI).
Co-authored-by: Martin Castro Laminrs <mcastro@laminr.ai>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 80dbe32 commit 2d388f3
2 files changed
Lines changed: 28 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
141 | 149 | | |
142 | 150 | | |
143 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
144 | 158 | | |
145 | 159 | | |
146 | 160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
| |||
0 commit comments