summaryrefslogtreecommitdiff
path: root/tests/model_forms/test_modelchoicefield.py
AgeCommit message (Collapse)Author
2026-04-22Fixed #35870 -- Made blank choice label in forms more accessible.Annabelle Wiegart
Added new constant django.db.models.fields.BLANK_CHOICE_LABEL for an accessible and translatable blank choice label in forms. Deprecated django.db.models.fields.BLANK_CHOICE_DASH constant. Added the immediately deprecated transitional setting USE_BLANK_CHOICE_DASH. Co-Authored-By: Marijke Luttekes <mail@marijkeluttekes.dev>
2026-02-10Modified tests to format PKs with %s rather than %d.Tim Graham
It's how Django formats values internally and makes tests compatible with databases that use non-integer primary keys.
2026-01-18Applied Black's 2026 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/26.1.0
2025-07-23Refs #36500 -- Rewrapped long docstrings and block comments via a script.django-bot
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
2024-06-17Fixed #35483 -- Added NUL (0x00) character validation to ModelChoiceFields.Alexander Lötvall
Applied the ProhibitNullCharactersValidator to ModelChoiceField and ModelMultipleChoiceField. Co-authored-by: Viktor Paripás <viktor.paripas@gmail.com> Co-authored-by: Vasyl Dizhak <vasyl@dizhak.com> Co-authored-by: Arthur Vasconcelos <vasconcelos.arthur@gmail.com>
2022-04-14Relaxed some query ordering assertions in various tests.Mariusz Felisiak
It accounts for differences seen on MySQL with MyISAM storage engine.
2022-02-07Refs #33476 -- Refactored code to strictly match 88 characters line length.Mariusz Felisiak
2022-02-07Refs #33476 -- Reformatted code with Black.django-bot
2021-09-30Fixed #33155 -- Made ModelChoiceIteratorValue instances hashable.Aljaž Košir
2021-08-27Refs #32338 -- Made RadioSelect/CheckboxSelectMultiple render in <div> tags.David Smith
This improves accessibility for screen reader users.
2020-04-28Changed django.forms.ValidationError imports to ↵François Freitag
django.core.exceptions.ValidationError. Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2020-02-05Fixed #26813 -- Prevented empty choice in ModelChoiceField with RadioSelect ↵Hasan Ramezani
for fields with blank=False.
2019-12-23Fixed #30998 -- Added ModelChoiceIteratorValue to pass the model instance to ↵Jon Dufresne
ChoiceWidget.create_option().
2019-12-11Fixed typo in ModelChoiceFieldTests.Jon Dufresne
The subindex and attrs arguments should be passed through to the parent, not overridden as None.
2019-10-11Fixed #30014 -- Fixed ModelChoiceField validation when initial value is a ↵Etienne Chové
model instance. Thanks Carlton Gibson for reviews.
2019-10-11Added ModelChoiceField test for validation with to_field_name.Etienne Chové
2018-04-23Refs #28312 -- Added an optimized __bool__() to ModelChoiceIterator.François Freitag
COUNT is more expensive than EXISTS; use the latter when possible.
2018-04-23Fixed #28312 -- Made ModelChoiceIterator.__len__() more memory-efficient.François Freitag
Instead of loading all QuerySet results in memory, count the number of entries. This adds an extra query when list() or tuple() is called on the choices (because both call __len__() then __iter__()) but uses less memory since the QuerySet results won't be cached. In most cases, the choices will only be iterated on, meaning that __len__() won't be called and only one query will be executed.
2018-03-01Fixed #29159 -- Made ModelChoiceIterator reuse QuerySet result cache.François Freitag
When __len__() is called (e.g. when casting to list or tuple), the QuerySet is evaluated and the result cache populated. iterator() shouldn't be called on the QuerySet after that, as it would reset the result cache and trigger a second query.
2018-03-01Fixed #29158 -- Fixed len(choices) crash if ModelChoiceField's queryset is a ↵François Freitag
manager. Removing all() in __iter__() prevents a duplicate query when choices are cast to a list and there's a prefetch_related().
2018-03-01Consolidated ModelChoiceField tests.François Freitag