Commit Graph

313 Commits

Author SHA1 Message Date
Mariusz Felisiak 7119f40c98 Refs #33476 -- Refactored code to strictly match 88 characters line length. 2022-02-07 20:37:05 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Mariusz Felisiak c5cd878382
Refs #33476 -- Refactored problematic code before reformatting by Black.
In these cases Black produces unexpected results, e.g.

def make_random_password(
    self,
    length=10,
    allowed_chars='abcdefghjkmnpqrstuvwxyz' 'ABCDEFGHJKLMNPQRSTUVWXYZ' '23456789',
):

or

cursor.execute("""
SELECT ...
""",
    [table name],
)
2022-02-03 11:20:46 +01:00
vgolubev e87f57fdb8 Fixed #26142 -- Allowed model formsets to prevent new object creation.
Thanks Jacob Walls, David Smith, and Mariusz Felisiak for reviews.

Co-authored-by: parth <parthvin@gmail.com>
2022-01-27 20:45:21 +01:00
Aljaž Košir 7b8beeee3d
Fixed #33155 -- Made ModelChoiceIteratorValue instances hashable. 2021-09-30 12:07:50 +02:00
David Smith 456466d932 Fixed #31026 -- Switched form rendering to template engine.
Thanks Carlton Gibson, Keryn Knight, Mariusz Felisiak, and Nick Pope
for reviews.

Co-authored-by: Johannes Hoppe <info@johanneshoppe.com>
2021-09-20 15:50:18 +02:00
taulant 0e8be73812 Fixed #32975 -- Fixed admin system check for inlines with foreign keys to proxy models. 2021-09-03 06:48:32 +02:00
Jerin Peter George 1adc09064f Fixed #32347 -- Made ModelChoiceField include the value in ValidationError for invalid_choice. 2021-01-26 09:31:53 +01:00
Mariusz Felisiak bf770cc825 Refs #8760 -- Removed "list" message for ModelMultipleChoiceField per deprecation timeline. 2021-01-14 17:50:04 +01:00
alvinshaita 556fa4bbba Fixed #1891, Fixed #11707 -- Prevented duplicates with limit_choices_to on multi-value relations. 2020-10-27 20:40:04 +01:00
David Smith e74b3d724e Bumped minimum isort version to 5.1.0.
Fixed inner imports per isort 5.
isort 5.0.0 to 5.1.0 was unstable.
2020-07-30 10:58:59 +02:00
David Smith 162765d6c3 Fixed #9061 -- Allowed FormSets to disable deleting extra forms.
Thanks to Dan Ward for the initial patch.
2020-06-24 09:26:25 +02:00
David Smith 433dd737f9 Fixed #20347 -- Allowed customizing the maximum number of instantiated forms in formsets.
Co-authored-by: ethurgood <ethurgood@gmail.com>
2020-06-05 12:01:32 +02:00
David Smith ccf32aca44 Fixed #8760 -- Changed ModelMultipleChoiceField to use invalid_list as a error message key. 2020-03-12 09:36:01 +01:00
Hasan Ramezani da79ee472d Fixed #26813 -- Prevented empty choice in ModelChoiceField with RadioSelect for fields with blank=False. 2020-02-05 10:27:01 +01:00
Nick Pope 335c9c94ac Simplified imports from django.db and django.contrib.gis.db. 2020-02-04 13:20:06 +01:00
Jon Dufresne 67ea35df52 Fixed #30998 -- Added ModelChoiceIteratorValue to pass the model instance to ChoiceWidget.create_option(). 2019-12-23 10:34:50 +01:00
Shubham singh f4647179cc Fixed #31086 -- Improved error message for admin model inlines with more than one foreign key to the same parent. 2019-12-17 09:15:01 +01:00
Jon Dufresne 86a0231e0a Refs #23919 -- Replaced super(...) with super() in metaclasses. 2019-11-28 15:34:29 +01:00
Etienne Chové e7cdb0cd7e Fixed #30014 -- Fixed ModelChoiceField validation when initial value is a model instance.
Thanks Carlton Gibson for reviews.
2019-10-11 13:28:09 +02:00
Jon Dufresne 42b9a23267 Fixed #30400 -- Improved typography of user facing strings.
Thanks Claude Paroz for assistance with translations.
2019-06-28 16:46:18 +02:00
Tobias Kunze a387ef1117 Added missing form argument in modelform_factory() docstring. 2019-06-20 15:13:22 +02:00
RobertAKARobin aa94f7c899 Fixed #30534 -- Fixed overriding a field's default in ModelForm.cleaned_data(). 2019-06-04 08:28:49 +02:00
belegnar 1ffddfc233
Fixed #30302 -- Fixed forms.model_to_dict() result if empty list of fields is passed. 2019-04-03 09:05:15 +02:00
Nick Pope 24b82cd201 Fixed #30159 -- Removed unneeded use of OrderedDict.
Dicts preserve order since Python 3.6.
2019-02-06 13:48:39 -05:00
Patrik Sletmo 14e2b1b065 Fixed #29981 -- Fixed inline formsets with a OnetoOneField primary key that uses to_field. 2019-01-01 10:40:22 -05:00
Jon Dufresne ef87b38ef7 Fixed #29696 -- Prevented BaseModelFormSet.initial_form_count()'s from treating data={} as unbound. 2018-08-21 10:02:03 -04:00
Demur Nodia 06a11ef6ec Fixed #26819 -- Fixed BaseModelFormSet.validate_unique() "unhashable type: list" crash. 2018-07-30 16:52:12 -04:00
Tim Graham 236bcfea42 Fixed #29474 -- Simplified BaseInlineFormset.save_new(). 2018-06-07 21:14:19 -04:00
François Freitag d1413c5d70 Refs #28312 -- Added an optimized __bool__() to ModelChoiceIterator.
COUNT is more expensive than EXISTS; use the latter when possible.
2018-04-23 13:03:07 -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
François Freitag a2e97abd81 Fixed #29159 -- Made ModelChoiceIterator reuse QuerySet result cache.
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-01 14:17:56 -05: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
Дилян Палаузов a38ae914d8 Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements. 2018-01-12 12:44:50 -05:00
Дилян Палаузов d79cf1e9e2 Fixed #28985 -- Removed unneeded None checks before hasattr(). 2018-01-03 11:37:06 -05:00
Nick Pope d13a9e44de Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking. 2017-12-11 07:08:45 -05:00
Дилян Палаузов d2afa5eb23 Fixed #28860 -- Removed unnecessary len() calls. 2017-12-04 10:35:23 -05:00
Mariusz Felisiak 0ec0e5029c Removed unnecessary parens in various code. 2017-09-13 21:20:29 -04:00
Mariusz Felisiak 0214f367bc Merged isinstance() calls. 2017-09-13 15:00:45 -04:00
Tim Graham 6e4c6281db Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365
because try/except performs better.
2017-09-07 08:16:21 -04:00
Sergey Fedoseev 38988f289f Avoided creation of temporary sets. 2017-07-29 10:16:43 -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 d7881d2020 Fixed #22229 -- Added primary key validation to BaseModelFormSet._construct_form(). 2017-07-11 14:33:21 -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
Mads Jensen 550cb3a365 Fixed #27818 -- Replaced try/except/pass with contextlib.suppress(). 2017-06-28 14:07:55 -04:00
Tom 3eb3907bb1 Refs #23919 -- Replaced stray super(ClassName, self) with super(). 2017-06-10 20:46:43 -04:00
Claude Paroz 43b574007e Fixed #28192 -- Required passing optional form field args as keyword args. 2017-06-03 10:49:01 -04:00
Jon Dufresne 2c69824e5a Refs #23968 -- Removed unnecessary lists, generators, and tuple calls. 2017-06-01 19:08:59 -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