summaryrefslogtreecommitdiff
path: root/django/contrib/admin/options.py
diff options
context:
space:
mode:
authorAnnabelle Wiegart <annabelle.wiegart@proton.me>2026-01-18 20:03:28 +0100
committerJacob Walls <jacobtylerwalls@gmail.com>2026-04-22 17:06:29 -0400
commit63c56cda133a85a158502891c40465bc0331d3d9 (patch)
tree04380903d14307b71416b2e048ce4be8361cf0df /django/contrib/admin/options.py
parentdc467fdc3b5744cec71fab876c23a14013e2510b (diff)
Fixed #35870 -- Made blank choice label in forms more accessible.
Added new constant django.db.models.fields.BLANK_CHOICE_LABEL for an accessible and translatable blank choice label in forms. Deprecated django.db.models.fields.BLANK_CHOICE_DASH constant. Added the immediately deprecated transitional setting USE_BLANK_CHOICE_DASH. Co-Authored-By: Marijke Luttekes <mail@marijkeluttekes.dev>
Diffstat (limited to 'django/contrib/admin/options.py')
-rw-r--r--django/contrib/admin/options.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index bb091e4c52..71d4a2d55c 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -43,6 +43,7 @@ from django.core.exceptions import (
from django.core.paginator import Paginator
from django.db import models, router, transaction
from django.db.models.constants import LOOKUP_SEP
+from django.db.models.utils import get_blank_choice_label
from django.forms.formsets import DELETION_FIELD_NAME, all_valid
from django.forms.models import (
BaseInlineFormSet,
@@ -1049,11 +1050,13 @@ class ModelAdmin(BaseModelAdmin):
actions = self._filter_actions_by_permissions(request, self._get_base_actions())
return {name: (func, name, desc) for func, name, desc in actions}
- def get_action_choices(self, request, default_choices=models.BLANK_CHOICE_DASH):
+ def get_action_choices(self, request, default_choices=None):
"""
Return a list of choices for use in a form object. Each choice is a
tuple (name, description).
"""
+ if default_choices is None:
+ default_choices = [("", get_blank_choice_label())]
choices = [*default_choices]
for func, name, description in self.get_actions(request).values():
choice = (name, description % model_format_dict(self.opts))