django-multiselectfield
django-multiselectfield copied to clipboard
Fixed IndexError with Django 4.1
Fix for issue #131.
Great job!
Nice ! Do you know if this project is actively maintained anymore ? When could we expect a release compatible with 4.1 ?
Thank you very much for your work 👍
We might need to ask @goinnn if the project is actively maintained or if he needs help maintaining it 😉
Hi! @macmichael01! I have the same stopper to migrate my application to 4.1.1 version, The way that I could resolve without this change was add max_length
as parameter, some like this: MultiSelectField(max_length=100...
. The value that you assign in max_length doesnt care because inside the code it will be replaced.
Now I have a suggenstion. Whay do you think if it assigns the max _length in the kwargs dictionary before to call super()
method? It leave the responsability to assign this value in django field class:
This is the line where django assigns that validation: https://github.com/django/django/blob/main/django/db/models/fields/init.py#L1119
The code can look like:
def __init__(self, *args, **kwargs):
self.min_choices = kwargs.pop('min_choices', None)
self.max_choices = kwargs.pop('max_choices', None)
choices = kwargs.get('kwargs', None)
kwargs.update({'max_length': get_max_length(choices, None)})
super(MultiSelectField, self).__init__(*args, **kwargs)
if self.min_choices is not None:
self.validators.append(MinChoicesValidator(self.min_choices))
if self.max_choices is not None:
self.validators.append(MaxChoicesValidator(self.max_choices))
@macmichael01 Any chance this can get reviewed and merged?
Please merge this PR and release the bug fix
@macmichael01 @goinnn please merge the PR. We have to do some Django upgrades and the plugin is blocking us.
Does this need the condition that it is only appended if there are no other validators declared? Or would simply just appending it be a bit better so that it doesn't get left out.
still experiencing this issue:)
Fixed in #148.