From cb5ba2a4015a0b0db74f00312843b5272db667d2 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 20 Nov 2024 15:41:45 +0100 Subject: [PATCH] Fix select2 for newer django versions --- select2/fields.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/select2/fields.py b/select2/fields.py index 144976a..2ad68e3 100644 --- a/select2/fields.py +++ b/select2/fields.py @@ -133,13 +133,12 @@ def __init__(self, search_field=None, case_sensitive=False, *args, **kwargs): self.choice_iterator_cls = kwargs.pop('choice_iterator_cls', self.choice_iterator_cls) super(Select2ModelFieldMixin, self).__init__(*args, **kwargs) - def _get_choices(self): + @Select2FieldMixin.choices.getter + def choices(self): if hasattr(self, '_choices'): return self._choices return self.choice_iterator_cls(self) - choices = property(_get_choices, forms.ChoiceField._set_choices) - class ModelChoiceField(Select2ModelFieldMixin, forms.ModelChoiceField):