8000 fix: django 5's choice widget is not lazy by fsbraun · Pull Request #7707 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

fix: django 5's choice widget is not lazy #7707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 30, 2023
Prev Previous commit
Next Next commit
Fix: Swapped underscore
  • Loading branch information
fsbraun committed Nov 29, 2023
commit 7bed55315ea1622063a91d112663134d05eeb173
4 changes: 2 additions & 2 deletions cms/forms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def choices(self, value):
# we overwrite this function so no list(value) or normalize_choices(value) is called
# also, do not call the widget's setter as of Django 5
if DJANGO_4_2:
self._choices = self.widget._choices = value
else:
self._choices = self.widget.choices = value
else:
self._choices = self.widget._choices = value


class PageSelectFormField(forms.MultiValueField):
Expand Down
6 changes: 2 additions & 4 deletions cms/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,8 @@ def get_choices():
choices_called = True
return ("", "-----"),

LazyChoiceField(
choices=get_choices
)
self.assertFalse(choices_called)
LazyChoiceField(choices=SuperLazyIterator(get_choices))
self.assertFalse(choices_called, "Lazy choice function called")


class PermissionFormTestCase(CMSTestCase):
Expand Down
0