From 9c6879284315d5119942355c340c3e48f6c65882 Mon Sep 17 00:00:00 2001 From: nessita <124304+nessita@users.noreply.github.com> Date: Fri, 1 Sep 2023 00:44:38 -0300 Subject: [PATCH] Fixed #34807 -- Avoided circular import between forms, models, and utils' choices. Thanks Collin Anderson for the report. Regression in 500e01073adda32d5149624ee9a5cb7aa3d3583f. --- django/utils/choices.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/django/utils/choices.py b/django/utils/choices.py index fc8267af343..ccedf828a0a 100644 --- a/django/utils/choices.py +++ b/django/utils/choices.py @@ -1,6 +1,5 @@ from collections.abc import Callable, Iterable, Iterator, Mapping -from django.db.models.enums import ChoicesMeta from django.utils.functional import Promise @@ -20,6 +19,8 @@ class CallableChoiceIterator(ChoiceIterator): def normalize_choices(value, *, depth=0): """Normalize choices values consistently for fields and widgets.""" + # Avoid circular import when importing django.forms. + from django.db.models.enums import ChoicesMeta match value: case ChoiceIterator() | Promise() | bytes() | str():