From 171f91d9ef5177850c2f12b26dd732785f6ac034 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Mon, 16 Oct 2023 19:11:18 +0100 Subject: [PATCH] Fixed #34899 -- Added blank choice to forms' callable choices lazily. --- django/db/models/fields/__init__.py | 10 +++------ django/utils/choices.py | 17 ++++++++++++++- tests/model_forms/tests.py | 33 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 6174b7bc98..205a41c193 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -16,6 +16,7 @@ from django.db.models.constants import LOOKUP_SEP from django.db.models.query_utils import DeferredAttribute, RegisterLookupMixin from django.utils import timezone from django.utils.choices import ( + BlankChoiceIterator, CallableChoiceIterator, flatten_choices, normalize_choices, @@ -1055,14 +1056,9 @@ class Field(RegisterLookupMixin): as