﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
36618	BaseForm.add_error() misleading exception message when both field and dict provided	Chris Brand	Nilesh Pahari	"This code creates a form and attempts to add an error for a single field to it:

{{{
from django import forms
from django.core.exceptions import ValidationError

class FooForm(forms.Form):
    the_field = forms.CharField(max_length=100)

exc = ValidationError({'the_field': 'Something is wrong with the field'})
form = FooForm()

form.add_error('the_field', exc)
}}}

It results in the following error message:
{{{
TypeError: The argument `field` must be `None` when the `error` argument contains errors for multiple fields.
}}}

The reference to ""errors for multiple fields"" is just wrong - the error in question is for a single field.

For background, in my case the ValidationError is raised by my custom Model.clean(). What I really want to do it to map it from the Model field to the form field (which in general may not have the same name). The error message was quite confusing.
"	Cleanup/optimization	closed	Forms	5.2	Normal	fixed			Ready for checkin	1	0	0	0	1	0
