django
django copied to clipboard
Fixed #27704 -- Used TypedMultipleChoiceField for ArrayFields with choices in base_field.
As per suggestions in @ngnpope's comment on #7850 made choices_form_class = TypedMultipleChoiceField
also removed support for ArrayField.choices
and instead ArrayField.base_field.choices
shall be used. Removed ArrayField.clean()
method intoduced in https://github.com/django/django/commit/9dd244394236388c3479ab202a0ec31055f7ec09 because SimpleArrayField
will no more be used while ArrayField
has choices and also shifted the test test_model_field_choices
introduced in https://github.com/django/django/commit/9dd244394236388c3479ab202a0ec31055f7ec09 to tests.postgres_tests.test_array.TestChoiceFormField
.
@ngnpope Do you want to take a look?
Committed the changes according to @ngnpope's review and added test for it although we still need to look for a fix for some shortcomings that I picked out in this comment.
@felixxm if someone could review 🙇🏻
@ngnpope can you have a look??
@jacobtylerwalls committed the suggested changes although the patch does not throws a warning if choices are not in base field
as far as i tested even though we have that in the patch and also the test works fine.
Ah, along the lines of this https://github.com/django/django/pull/15805#discussion_r921342795?
You could consider changing the warning to a system check as Nick suggested.
Ah, along the lines of this #15805 (comment)?
You could consider changing the warning to a system check as Nick suggested.
Got it 👍🏻 will look into it
Ah, along the lines of this #15805 (comment)?
You could consider changing the warning to a system check as Nick suggested.
So we would have to raise an error on running the makemigrations
command right?
Also according to our current change that wouldn't be possible cause we would only be able to check it once the ArrayField.formfield()
is called.
Have a look at the documentation for field checks. This is what I was referring to.
Closing due to inactivity.