Skip to content
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

Fixed IndexError with Django 4.1 #132

Closed
wants to merge 1 commit into from

Conversation

macmichael01
Copy link

Fix for issue #131.

@dennybiasiolli
Copy link

Great job!

@girardinsamuel
Copy link

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 👍

@dennybiasiolli
Copy link

We might need to ask @goinnn if the project is actively maintained or if he needs help maintaining it 😉

@Fabfm4
Copy link

Fabfm4 commented Sep 26, 2022

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))

@Afani97
Copy link

Afani97 commented Oct 27, 2022

@macmichael01 Any chance this can get reviewed and merged?

@sar009
Copy link

sar009 commented Nov 10, 2022

Please merge this PR and release the bug fix

@sar009
Copy link

sar009 commented Nov 24, 2022

@macmichael01 @goinnn please merge the PR. We have to do some Django upgrades and the plugin is blocking us.

@clhVEGAS
Copy link

clhVEGAS commented Jan 8, 2023

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.

Maffooch added a commit to DefectDojo/django-multiselectfield that referenced this pull request Jan 9, 2023
gcjulz added a commit to gcjulz/django-multiselectfield that referenced this pull request Feb 15, 2023
@sewagodimo
Copy link

still experiencing this issue:)

@blag
Copy link
Collaborator

blag commented May 23, 2024

Fixed in #148.

@blag blag closed this May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants