Fixed #34807 -- Avoided circular import between forms, models, and utils' choices.

Thanks Collin Anderson for the report.

Regression in 500e01073a.
This commit is contained in:
nessita 2023-09-01 00:44:38 -03:00 committed by GitHub
parent c74a6fad54
commit 9c68792843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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():