Closed aliceni81 closed 6 months ago
I was also wondering why my data was not being fetched. Spent hours debugging. Thanks for this! It helped me save so much time.
In my application, simply removing those lines breaks the display in the admin view. I recommend keeping the code, but replacing
flat_choices = super(MultiSelectField, self)._get_flatchoices()
by
flat_choices = super(MultiSelectField, self).flatchoices
or
try:
flat_choices = super(MultiSelectField, self).flatchoices
except AttributeError:
flat_choices = super(MultiSelectField, self)._get_flatchoices()
for backwards compatibility
Big thanks, everyone! I was struggling to figure out how to fix it.
The current version is incompatible with Django 5.0. There is no _get_flatchoices in django's CharField anymore, instead Django provides flatchoices directly. Therefore, the following code in db/fields.py should be removed.