summaryrefslogtreecommitdiff
path: root/django/conf/__init__.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/conf/__init__.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/conf/__init__.py')
-rw-r--r--django/conf/__init__.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/django/conf/__init__.py b/django/conf/__init__.py
index c7ae36aba0..25f5ffa305 100644
--- a/django/conf/__init__.py
+++ b/django/conf/__init__.py
@@ -16,12 +16,19 @@ from pathlib import Path
import django
from django.conf import global_settings
from django.core.exceptions import ImproperlyConfigured
+from django.utils.deprecation import RemovedInDjango70Warning, django_file_prefixes
from django.utils.functional import LazyObject, empty
ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
DEFAULT_STORAGE_ALIAS = "default"
STATICFILES_STORAGE_ALIAS = "staticfiles"
+USE_BLANK_CHOICE_DASH_DEPRECATED_MSG = (
+ "The USE_BLANK_CHOICE_DASH setting is deprecated. If you wish to define "
+ "your own default blank choice label, override "
+ "django.db.models.fields.BLANK_CHOICE_LABEL in your app's ready() method."
+)
+
class SettingsReference(str):
"""
@@ -226,6 +233,12 @@ class UserSettingsHolder:
def __setattr__(self, name, value):
self._deleted.discard(name)
+ if name == "USE_BLANK_CHOICE_DASH":
+ warnings.warn(
+ USE_BLANK_CHOICE_DASH_DEPRECATED_MSG,
+ RemovedInDjango70Warning,
+ skip_file_prefixes=django_file_prefixes(),
+ )
super().__setattr__(name, value)
def __delattr__(self, name):