diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2021-01-13 16:19:22 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-13 17:19:22 +0100 |
| commit | 920448539631b52dcee53bd32a880abbc9de18bd (patch) | |
| tree | 03dd52fd206088302de11e0b485b420726718a4a /docs/topics | |
| parent | 83fcfc9ec8610540948815e127101f1206562ead (diff) | |
Fixed #16117 -- Added decorators for admin action and display functions.
Refs #25134, #32099.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/i18n/translation.txt | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/docs/topics/i18n/translation.txt b/docs/topics/i18n/translation.txt index 7a7bf85ebc..1819359725 100644 --- a/docs/topics/i18n/translation.txt +++ b/docs/topics/i18n/translation.txt @@ -389,12 +389,14 @@ verbose names Django performs by looking at the model's class name:: verbose_name = _('my thing') verbose_name_plural = _('my things') -Model methods ``short_description`` attribute values -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Model methods ``description`` argument to the ``@display`` decorator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For model methods, you can provide translations to Django and the admin site -with the ``short_description`` attribute:: +with the ``description`` argument to the :func:`~django.contrib.admin.display` +decorator:: + from django.contrib import admin from django.db import models from django.utils.translation import gettext_lazy as _ @@ -406,9 +408,9 @@ with the ``short_description`` attribute:: verbose_name=_('kind'), ) + @admin.display(description=_('Is it a mouse?')) def is_mouse(self): return self.kind.type == MOUSE_TYPE - is_mouse.short_description = _('Is it a mouse?') Working with lazy translation objects ------------------------------------- |
