Add 'custom_user' to INSTALLED_APPS and set AUTH_USER_MODEL =
'custom_user.EmailUser'
Run ./manage.py test custom_user
The test custom_user.tests.EmailUserCreationFormTest.test_invalid_data
fails. Here is the code:
{{{
data = {
'email': 'testclient',
'password1': 'test123',
'password2': 'test123',
}
form = EmailUserCreationForm(data)
self.assertFalse(form.is_valid())
self.assertEqual(form["email"].errors,
[force_text(form.fields['email'].error_messages['invalid'])])
}}}
In Django 1.6c1,
{{{
form.fields['email'].error_messages
}}}
has 'required' as a key and its corresponding message instead of
'invalid' and its corresponding message.
In Django 1.5.5, it works fine.
--
Ticket URL: <https://code.djangoproject.com/ticket/21339>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* severity: Normal => Release blocker
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
* type: Bug => Cleanup/optimization
* stage: Unreviewed => Accepted
Comment:
Ticket at the origin of the change is #17051, commit is [2f121dfe635b3f].
The rationale is that the error message is not primarily set by the form
field, but by the validator(s) attached to the field.
In Django 1.6, the test above should be:
{{{
from django.core.validators import EmailValidator
self.assertEqual(form["email"].errors,
[force_text(EmailValidator.message)])
}}}
Accepted on the base that a note might be added in the ''Backwards
incompatible changes in 1.6'' section of the release notes.
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:1>
* has_patch: 0 => 1
Comment:
Proposal:
{{{
diff --git a/docs/releases/1.6.txt b/docs/releases/1.6.txt
index 651938e..afa44d2 100644
--- a/docs/releases/1.6.txt
+++ b/docs/releases/1.6.txt
@@ -830,6 +830,10 @@ Miscellaneous
changes in 1.6 particularly affect :class:`~django.forms.DecimalField`
and
:class:`~django.forms.ModelMultipleChoiceField`.
+* Several form field's :attr:`~django.forms.Field.error_messages` have
been
+ suppressed because they were duplicates of error messages coming from
the
+ appropriate field validator(s).
+
* There have been changes in the way timeouts are handled in cache
backends.
Explicitly passing in ``timeout=None`` no longer results in using the
default timeout. It will now set a non-expiring timeout. Passing 0 into
the
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:2>
* needs_better_patch: 0 => 1
Comment:
I think we should also include an example like the one offered in the
description. Reading the note without reading the rest of the this ticket
left me wondering what it meant.
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:3>
Comment (by aaugustin):
I don't think we've documented the field error messages and guarantee
backwards compatibility for them.
Of course more documentation is generally better, we can add this to the
release notes.
Claude, I suggest listing all fields, to make the message as useful as
possible. Proposal:
{{{
* Some :attr:`~django.forms.Field.error_messages` for
:class:`~django.forms.fields.IntegerField`,
:class:`~django.forms.fields.EmailField`,
:class:`~django.forms.fields.IPAddressField`,
:class:`~django.forms.fields.GenericIPAddressField`, and
:class:`~django.forms.fields.SlugField` have been suppressed because they
duplicated error messages already provided by validators tied to the
fields.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"0d9c1499901480ed52c08e1b94ecc80c7b55bc0e"]:
{{{
#!CommitTicketReference repository=""
revision="0d9c1499901480ed52c08e1b94ecc80c7b55bc0e"
Fixed #21339 -- Documented removal of some form field error messages
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:5>
Comment (by Claude Paroz <claude@…>):
In [changeset:"8f104bb8d51835c240bbc7f468032b798a263b24"]:
{{{
#!CommitTicketReference repository=""
revision="8f104bb8d51835c240bbc7f468032b798a263b24"
[1.6.x] Fixed #21339 -- Documented removal of some form field error
messages
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21339#comment:6>