Commit Graph

198 Commits

Author SHA1 Message Date
Niclas Olofsson cdc25ac474 Fixed #22808 -- Made ModelMultipleChoiceField validation more robust to invalid data types..
Thanks Mattias Lindvall for the report and inital patch.
2014-07-31 15:29:46 -04:00
Tim Graham 5e2c4a4bd1 Fixed #13794 -- Fixed to_field usage in BaseInlineFormSet.
Thanks sebastien at clarisys.fr for the report and gautier
for the patch.
2014-07-09 07:59:20 -04:00
Daniel Hahler 67f9f385aa Fixed various minor doc typos / references. 2014-07-05 20:26:26 -04:00
Marc Tamlyn 2764146586 Fixed #22838 -- Deprecated ModelChoiceField.cache_choices.
Undocumented, untested and probably not even useful feature.
2014-06-20 20:29:46 +01:00
Anubhav Joshi 45e049937d Fixed #13776 -- Fixed ModelForm.is_valid() exception with non-nullable FK and blank=True.
Thanks peterbe for the report.
2014-06-04 07:57:19 -04:00
Anders Steinlein 4ef10f245a Fixed #17642 -- Added min_num support to modelformsets, inlines, and the admin.
Thanks Stephen Burrows for work on the patch as well.

Forwardport of 2914f66983 from stable/1.7.x
2014-05-15 07:25:35 -04:00
Alex Gaynor 778ce245dd Corrected many style guide violations that the newest version of flake8 catches 2014-03-30 12:11:05 -07:00
Tim Graham ee4edb1eda Made ModelForms raise ImproperlyConfigured if the list of fields is not specified.
Also applies to modelform(set)_factory and generic model views.

refs #19733.
2014-03-22 07:56:48 -04:00
Tim Graham e80de93af6 Removed hard-coded help_text for ManyToManyFields that use a SelectMultiple widget
Per deprecation timeline; refs #9321.
2014-03-21 19:10:07 -04:00
Claude Paroz 210d0489c5 Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings
Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
2014-03-08 09:57:40 +01:00
Christopher Adams eefc88feef Fixed #2445 -- Allowed limit_choices_to attribute to be a callable.
ForeignKey or ManyToManyField attribute ``limit_choices_to`` can now
be a callable that returns either a ``Q`` object or a dict.

Thanks michael at actrix.gen.nz for the original suggestion.
2014-02-11 14:05:12 -05:00
Loic Bistuer 8847a0c601 Fixed #16192 -- Made unique error messages in ModelForm customizable.
Overriding the error messages now works for both unique fields, unique_together
and unique_for_date.

This patch changed the overriding logic to allow customizing NON_FIELD_ERRORS
since previously only fields' errors were customizable.

Refs #20199.

Thanks leahculver for the suggestion.
2014-02-08 04:59:09 -05:00
Russell Keith-Magee d818e0c9b2 Fixed #16905 -- Added extensible checks (nee validation) framework
This is the result of Christopher Medrela's 2013 Summer of Code project.

Thanks also to Preston Holmes, Tim Graham, Anssi Kääriäinen, Florian
Apolloner, and Alex Gaynor for review notes along the way.

Also: Fixes #8579, fixes #3055, fixes #19844.
2014-01-20 10:45:21 +08:00
Loic Bistuer 6685713869 Fixed E127 pep8 warnings. 2013-12-14 11:59:15 -05:00
Claude Paroz 8a9c8bb907 Fixed #21568 -- Added missing ModelMultipleChoiceField to_python method
Thanks dibrovsd at gmail.com for the report and Simon Charette
for the review.
2013-12-07 10:14:22 +01:00
Loic Bistuer f563c339ca Fixed #20867 -- Added the Form.add_error() method.
Refs #20199 #16986.

Thanks @akaariai, @bmispelon, @mjtamlyn, @timgraham for the reviews.
2013-11-30 01:00:53 +07:00
Christopher Medrela 7477a4ffde Fixed E125 pep8 warnings 2013-11-28 08:50:11 -05:00
Loic Bistuer 1c7a83ee8e Fixed #21489 -- Make formsets directly importable from django.forms. 2013-11-25 19:16:19 -05:00
Claude Paroz fafb6cf049 Fixed #21472 -- Fixed inline formsets display when parent pk is 0
Thanks agale031176@gmail.com for the report.
2013-11-20 21:36:20 +01:00
Anssi Kääriäinen 326539f6a4 Fixed a regression caused by fix for #21428
On Python 3 sorting Fields mixed with GenericForeignKeys doesn't work
as GenericForeignKey isn't a subclass of django.db.models.fields.Field.

Refs #21428.
2013-11-16 20:54:36 +02:00
Anssi Kääriäinen 0e079e4331 Fixed #21428 -- editable GenericRelation regression
The GenericRelation refactoring removed GenericRelations from
model._meta.many_to_many. This had the side effect of disallowing
editable GenericRelations in ModelForms. Editable GenericRelations
aren't officially supported, but if we don't fix this we don't offer any
upgrade path for those who used the ability to set editable=True
in GenericRelation subclass.

Thanks to Trac alias joshcartme for the report and stephencmd and Loic
for working on this issue.
2013-11-16 20:07:35 +02:00
Alex Gaynor c347f78cc1 Fixed all E226 violations 2013-11-03 10:08:55 -08:00
Jim Bailey 539e3693d4 Fixed #20849 -- ModelForms do not work well with prefetch_related.
model_to_dict() (used when rendering forms) queries the database
to get the list of primary keys for ManyToMany fields. This is
unnecessary if the field queryset has been prefetched, all the
keys are already in memory and can be obtained with a simple
iteration.
2013-11-03 12:27:54 +02:00
Anssi Kääriäinen efb0100ee6 Fixed #14877 -- repeated deletion using formsets
When a formset contained deletion for an existing instance, and the
instance was already deleted, django threw an exception. A common cause for
this was resubmit of the formset.

Original patch by Trac alias olau.

In addition this commit cleaned some code in _construct_form(). This
was needed as the primary key value the user submitted wasn't converted
correctly to python value in case the primary key field was also a
related field.
2013-10-30 22:40:15 +02:00
Alex Gaynor 9bf5610890 Start attacking E231 violations 2013-10-24 10:30:03 -07:00
Alasdair Nicol c3aa2948c6 Fixed #21298 -- Fixed E301 pep8 warnings 2013-10-23 13:45:03 +01:00
Alasdair Nicol b289fcf1bf Fixed #21288 -- Fixed E126 pep8 warnings 2013-10-21 08:31:30 -04:00
Alasdair Nicol a800036981 Fixed #21287 -- Fixed E123 pep8 warnings 2013-10-18 10:07:39 +01:00
Alasdair Nicol bab9123daa Fixed #21268 -- Fixed E303 pep8 warnings 2013-10-18 01:46:24 +01:00
Loic Bistuer ac5ec7b8bc Fixed #19617 -- Refactored Form metaclasses to support more inheritance scenarios.
Thanks apollo13, funkybob and mjtamlyn for the reviews.
2013-10-14 21:59:30 +07:00
Tim Graham 18ffdb1772 Fixed #17627 -- Renamed util.py files to utils.py
Thanks PaulM for the suggestion and Luke Granger-Brown and
Wiktor Kołodziej for the initial patch.
2013-09-16 12:52:05 -04:00
Simon Charette 11cd7388f7 Fixed #20989 -- Removed useless explicit list comprehensions. 2013-08-30 10:57:51 -04:00
Tim Graham c7d0ff0cad Fixed #20989 -- Removed explicit list comprehension inside dict() and tuple()
Thanks jeroen.pulles at redslider.net for the suggestion and
helper script.
2013-08-29 12:11:03 -04:00
Anssi Kääriäinen 6af05e7a0f Fixed model.__eq__ and __hash__ for no pk value cases
The __eq__ method now considers two instances without primary key value
equal only when they have same id(). The __hash__ method raises
TypeError for no primary key case.

Fixed #18864, fixed #18250

Thanks to Tim Graham for docs review.
2013-08-22 17:24:07 +03:00
Curtis Maloney 07876cf02b Deprecated SortedDict (replaced with collections.OrderedDict)
Thanks Loic Bistuer for the review.
2013-08-04 07:09:39 -04:00
Claude Paroz 5c1143910e Removed most of absolute_import imports
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
2013-07-29 20:28:13 +02:00
Tim Graham 65e03a424e Fixed #10284 -- ModelFormSet.save(commit=False) no longer deletes objects
Thanks laureline.guerin@ and Wedg.
2013-07-23 16:21:23 -04:00
Claude Paroz 7557207983 Fixed #20582 -- Allowed default Form.label_suffix to be translated
Thanks Tim Graham for the review.
2013-07-13 16:19:16 +02:00
Aymeric Augustin acd7b34aaf Advanced deprecation warnings for Django 1.7. 2013-06-29 18:49:37 +02:00
Loic Bistuer ee77d4b253 Fixed #20199 -- Allow ModelForm fields to override error_messages from model fields 2013-06-18 08:01:17 -04:00
Loic Bistuer f34cfec0fa Refactored ValidationError to allow persisting error params and error codes as the exception bubbles up 2013-06-18 08:01:17 -04:00
Loic Bistuer 9e50833e22 Fixed #20000 -- Allowed ModelForm meta overrides for label, help_text and error_messages 2013-06-13 15:06:25 -04:00
Stephen Burrows e2518fdf46 Fixed #12337 - Honor ModelForm.Meta.exclude when saving ManyToManyFields.
Thanks margieroginski for the report.
2013-06-06 10:01:48 -04:00
Claude Paroz 571864c845 Added missing stacklevel arg in forms/models.py 2013-05-30 20:07:53 +02:00
Ramiro Morales 8c2fd050f8 Made fix for #9321 less buggy and more effective.
Don't try to be smart about building a good-looking help string
because it evaluates translations too early, simply use the same old
strategy as before. Thanks Donald Stufft for the report.

Also, actually fix the case reported by the OP by special-casing
CheckboxSelectMultiple.

Added tests.

Refs #9321.
2013-05-23 07:49:29 -03:00
Ramiro Morales 4ba1c2e785 Fixed #9321 -- Deprecated hard-coding of help text in model ManyToManyField fields.
This is backward incompatible for custom form field/widgets that rely
on the hard-coded 'Hold down "Control", or "Command" on a Mac, to select
more than one.' sentence.

Application that use standard model form fields and widgets aren't
affected but need to start handling these help texts by themselves
before Django 1.8.

For more details, see the related release notes and deprecation timeline
sections added with this commit.
2013-05-20 16:29:51 -03:00
Erik Romijn 1c1695668f Fixed argument order for localized_fields to ensure backwards compatibility 2013-05-18 14:38:45 +02:00
Erik Romijn 756b81dbd1 Fixed #13546 -- Easier handling of localize field options in ModelForm 2013-05-18 14:13:00 +02:00
Luke Plant f026a519ae Fixed #19733 - deprecated ModelForms without 'fields' or 'exclude', and added '__all__' shortcut
This also updates all dependent functionality, including modelform_factory
 and modelformset_factory, and the generic views `ModelFormMixin`,
 `CreateView` and `UpdateView` which gain a new `fields` attribute.
2013-05-09 16:44:36 +01:00
Claude Paroz be9ae693c4 Fixed #17840 -- Generalized named placeholders in form error messages
Also fixed plural messages for DecimalField.
2013-04-13 18:55:50 +02:00