Commit Graph

138 Commits

Author SHA1 Message Date
Tim Graham 0004daa536
Used 4 space hanging indent for dictionaries.
Thanks Mariusz Felisiak for auditing.
2019-01-02 18:18:19 -05:00
Simon Charette 84e7a9f4a7 Switched setUp() to setUpTestData() where possible in Django's tests. 2018-11-27 09:35:17 -05:00
Tim Graham 193c109327 Switched TestCase to SimpleTestCase where possible in Django's tests. 2018-11-27 08:58:44 -05:00
Carlton Gibson 1c05fe65f2 Refs #13091 -- Added test for commit=False idiom with partial unique_together validation. 2018-07-25 18:39:35 -04:00
François Freitag 3fca95e1ad Fixed #28312 -- Made ModelChoiceIterator.__len__() more memory-efficient.
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-04-23 12:39:43 -04:00
Dan Watson e163effecc Fixed #29279 -- Added renderer argument to ModelForm. 2018-03-31 20:45:59 -04:00
Mariusz Felisiak 362813d628
Fixed hanging indentation in various code. 2018-03-16 10:54:34 +01:00
François Freitag 40f0aa9885 Fixed #29158 -- Fixed len(choices) crash if ModelChoiceField's queryset is a manager.
Removing all() in __iter__() prevents a duplicate query when choices are
cast to a list and there's a prefetch_related().
2018-03-01 14:12:14 -05:00
François Freitag 06172d7bc2 Consolidated ModelChoiceField tests. 2018-03-01 14:05:35 -05:00
Tim Graham 3fb718f17d Eliminated the need to modify a model forms test when new test files are added. 2018-02-28 10:26:26 -05:00
Jon Dufresne ff05de760c Fixed #29038 -- Removed closing slash from HTML void tags. 2018-01-21 02:09:10 -05:00
Jon Dufresne 47d238b696 Fixed #29041 -- Changed SelectMultiple's multiple attribute to HTML5 boolean syntax. 2018-01-20 11:19:06 -05:00
Tim Graham e5bd585c6e Fixed #28543 -- Prevented ManyToManyField.value_from_object() from being lazy.
Previously, it was a QuerySet which could reevaluate to a new value if the
model's data changes. This is inconsistent with other Field.value_from_object()
methods.

This allows reverting the fix in the admin for refs #27998.
2017-08-31 09:34:44 -04:00
Mads Jensen a51c4de194 Used assertRaisesMessage() to test Django's error messages. 2017-07-29 19:07:23 -04:00
Srinivas Reddy Thatiparthy 5debbdfcc8 Fixed #28387 -- Fixed has_changed() for disabled form fields that subclass it. 2017-07-14 13:06:51 -04:00
Jon Dufresne a1be12fe19 Fixed #28345 -- Applied limit_choices_to during ModelForm.__init__().
field_for_model() now has an additional keyword argument,
apply_limit_choices_to, allowing it to continue to be used to create
form fields dynamically after ModelForm.__init__() is called.

Thanks Tim Graham for the review.
2017-06-30 15:57:48 -07:00
Tom 3eb3907bb1 Refs #23919 -- Replaced stray super(ClassName, self) with super(). 2017-06-10 20:46:43 -04:00
Manatsawin Hanmongkolchai a0c07d77fc Fixed #28242 -- Moved ImageField file extension validation to the form field. 2017-06-01 10:13:23 -04:00
Jon Dufresne 21046e7773 Fixed #28249 -- Removed unnecessary dict.keys() calls.
iter(dict) is equivalent to iter(dict.keys()).
2017-05-27 19:08:46 -04:00
heathervm 7d1e237753 Fixed #27993 -- Fixed model form default fallback for SelectMultiple. 2017-03-31 10:10:08 -04:00
James Beith 216bb2e8fb Fixed #27975 -- Fixed crash if ModelChoiceField's queryset=None.
Regression in 9153d8fbd6385db9f48793662de789fc3d686841.
2017-03-22 08:51:12 -04:00
Mariusz Felisiak 2767ef3ca7 Fixed nondeterministic ordering test failure in model_forms. 2017-03-16 11:14:51 -04:00
Tim Graham 44f9241c48 Refs #27563 -- Fixed ModelChoiceField.__deepcopy__() so forms don't share a queryset cache.
Thanks Luke Benstead for the report Simon Charettes for the fix.
2017-03-15 12:54:26 -04:00
Tim Graham d6e26e5b7c Removed obsolete references to form_for_instance(). 2017-02-28 07:37:25 -05:00
Jon Dufresne 6d8979f4c2 Fixed #27758 -- Reallowed AdvancedModelIterator pattern after template widget rendering. 2017-01-31 09:41:51 -05:00
chillaranand d6eaf7c018 Refs #23919 -- Replaced super(ClassName, self) with super(). 2017-01-25 12:23:46 -05:00
Tim Graham 4e729feaa6 Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Simon Charette 9695b14982 Refs #23919 -- Removed str() conversion of type and method __name__. 2017-01-19 11:31:07 -05:00
Simon Charette cecc079168 Refs #23919 -- Stopped inheriting from object to define new style classes. 2017-01-19 08:39:46 +01:00
Claude Paroz 2b281cc35e Refs #23919 -- Removed most of remaining six usage
Thanks Tim Graham for the review.
2017-01-18 21:33:28 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz d7b9aaa366 Refs #23919 -- Removed encoding preambles and future imports 2017-01-18 09:55:19 +01:00
Tim Graham bcf3532ede Refs #26154 -- Removed deprecated CommaSeparatedIntegerField. 2017-01-17 20:52:02 -05:00
Josef Rousek aaecf038ca Fixed #27370 -- Prevented Select widget from using 'required' with a non-empty first value. 2016-12-28 10:45:22 -05:00
Preston Timmons b52c73008a Fixed #15667 -- Added template-based widget rendering.
Thanks Carl Meyer and Tim Graham for contributing to the patch.
2016-12-27 17:50:10 -05:00
Tim Graham 7ed456063b Updated LimitChoicesToTests to use setUpTestData and cosmetic edits. 2016-12-02 14:46:52 -05:00
Jon Dufresne 6abd6c598e Fixed #27563 -- Moved "apply limit_choices_to" code from BaseModelForm to fields_for_model(). 2016-12-02 08:40:24 -08:00
za 321e94fa41 Refs #27392 -- Removed "Tests that", "Ensures that", etc. from test docstrings. 2016-11-10 21:30:21 -05:00
Michal Petrucha 09da1e79de Fixed #27369 -- Prevented widgets from being shared between form field instances. 2016-11-06 07:16:56 +01:00
Tim Graham 87c5e7efeb Refs #27186 -- Fixed model form default fallback for CheckboxSelectMultiple. 2016-09-30 14:49:50 -04:00
Tim Graham 3507d4e773 Fixed #27186 -- Fixed model form default fallback for MultiWidget, FileInput, SplitDateTimeWidget, SelectDateWidget, and SplitArrayWidget.
Thanks Matt Westcott for the review.
2016-09-22 12:20:58 -04:00
Jon Dufresne 2c716c1dc7 Fixed #27256 -- Changed Select widget's selected attribute to use HTML5 boolean syntax. 2016-09-21 15:12:13 -07:00
Tim Graham dab653cadc Organized forms_tests test_regressions.py. 2016-09-09 08:55:29 -04:00
Alex Hill d9c083cfee Refs #27039 -- Fixed regression with field defaults in prefixed forms. 2016-09-01 09:13:21 -04:00
Tim Graham 4bc6b93994 Fixed #27039 -- Fixed empty data fallback to model field default in model forms. 2016-08-24 17:50:10 -04:00
Alex Hill 74105b2636 Fixed #27002 -- Prevented double query when rendering ModelChoiceField. 2016-08-08 13:41:05 -04:00
Alex Hill c5ebfda002 Fixed #27001 -- Fixed a query count regression in ModelChoiceField with RadioSelect. 2016-08-03 10:45:55 -04:00
Tim Graham 4e86168290 Fixed #26970 -- Fixed crash with disabled ModelMultipleChoiceField. 2016-07-30 13:31:48 -04:00
Tim Graham a5f85d891b Fixed #26917 -- Fixed crash in disabled ModelChoiceFields.
Partially reverted refs #25532 to fix a regression in Django 1.10.
This reintroduces a crash for disabled forms.JSONField (refs #26949),
however, that issue is also present on Django 1.9.

Thanks Ryan Schave for the test.
2016-07-27 08:14:14 -04:00
Andrey Fedoseev 81963b37a9 Fixed #17657 -- Made ModelForm respect ModelMultipleChoiceField's to_field_name.
Follow up to 67d984413c.
2016-07-12 16:20:06 -04:00