-
Notifications
You must be signed in to change notification settings - Fork 208
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
IndexError with Django 4.1 #131
Comments
This also holds for Django 4.0. |
I am seeing the same issue after an upgrade from django 4.0.7 to 4.1.2 Thanks for the workaround. |
Thanks for that.
|
Multi
MultiChoices not defined. |
@PraveenChordia Set from multiselectfield import MultiSelectField
from multiselectfield.utils import get_max_length
class TestModel(models.Model):
MULTIFIELD_CHOICES = (
('read', 'Code'),
('you', 'Copy'),
)
multifield = MultiSelectField(
choices=MULTIFIELD_CHOICES,
max_length=get_max_length(MULTIFIELD_CHOICES, None),
) |
* `SuccessURLAllowedHostsMixin` (used in `LoginView`) has been replaced by `RedirectURLMixin` (see https://docs.djangoproject.com/en/4.1/releases/4.1/#miscellaneous). * Logging out via GET is deprecated in favor of POST (see https://docs.djangoproject.com/en/4.1/releases/4.1/#log-out-via-get), so added a logout form to the header which is used instead of the previous <a> button, and which appears when not using Dataporten for auth. `dataporten.views.Logout` can keep using GET, though it should ideally be replaced by POST as well. * Added the `USES_DATAPORTEN_AUTH` custom setting for use in both `web/context_processors.py` and `web/urls.py` * Made the `defer` dicts in `make_queue/forms.py` and `web/multilingual/widgets.py` use boolean values, now that it's supported by `django-js-asset` due to the changes in Django 4.1 (see matthiask/django-js-asset@3785c6c) * Explicitly set `max_length` of `ReservationRule.start_days`, due to goinnn/django-multiselectfield#131
* We have to declare `max_length` on `Survey.data_type` because of goinnn/django-multiselectfield#131 * `url` has been removed and replaced by `re_path * The migration was auto-generated, I'm not completely sure by what.
* We have to declare `max_length` on `Survey.data_type` because of goinnn/django-multiselectfield#131 * `url` has been removed and replaced by `re_path` * The migration was auto-generated, I'm not completely sure by what.
* We have to declare `max_length` on `Survey.data_type` because of goinnn/django-multiselectfield#131 * `url` has been removed and replaced by `re_path` * The migration was auto-generated, I'm not completely sure by what.
Django 4.1 support has already ended, but we still test against Django 4.2 and 5.0, and tests are passing. Closing, since I think we fixed this in #148 and elsewhere. |
The error message is as follows:
File "*****lib/python3.9/site-packages/multiselectfield/db/fields.py", line 72, in init
self.validators[0] = MaxValueMultiFieldValidator(self.max_length)
IndexError: list assignment index out of range
Steps to reproduce:
Use a MultiSelectField without explicitly specifying max_lenght attribute
Reason for failure is the following django commit:
django/django@0ed2919
Obviously, django team realized that always adding a MaxValueFieldValidator if max_lenght is omitted is not a good idea for derived classes (like MultiSelectField) and
explicitly specify max_length in MultiSelectField, this should lead to old behaviour even with Django 4.1
Drawback is that this disables the automatic max_length computation of this packages. Therefore be careful to choose max_lenght big enough
The text was updated successfully, but these errors were encountered: