From 4a097466ebfa3260917c66f8a1e6f2891ebae399 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Thu, 31 Aug 2023 09:42:04 +0100 Subject: [PATCH] Fix CallableChoiceIterator import on Django 5.0+ --- wagtail/blocks/field_block.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wagtail/blocks/field_block.py b/wagtail/blocks/field_block.py index f0ddeccb8b..9cc7f86984 100644 --- a/wagtail/blocks/field_block.py +++ b/wagtail/blocks/field_block.py @@ -4,7 +4,6 @@ from decimal import Decimal from django import forms from django.db.models import Model from django.db.models.fields import BLANK_CHOICE_DASH -from django.forms.fields import CallableChoiceIterator from django.utils.dateparse import parse_date, parse_datetime, parse_time from django.utils.encoding import force_str from django.utils.functional import cached_property @@ -24,6 +23,12 @@ from wagtail.telepath import Adapter, register from .base import Block +try: + from django.utils.choices import CallableChoiceIterator +except ImportError: + # DJANGO_VERSION < 5.0 + from django.forms.fields import CallableChoiceIterator + class FieldBlock(Block): """A block that wraps a Django form field"""