diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 22546c27de..23be549224 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -890,6 +890,9 @@ class EmailField(CharField): description = _("E-mail address") def __init__(self, *args, **kwargs): + # max_length should be overridden to 254 characters to be fully + # compliant with RFCs 3696 and 5321 + kwargs['max_length'] = kwargs.get('max_length', 75) CharField.__init__(self, *args, **kwargs) diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 36bf60e9ac..8c6a2c9d35 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -481,6 +481,15 @@ The admin represents this as an ```` (a single-line input). A :class:`CharField` that checks that the value is a valid email address. +.. admonition:: Incompliance to RFCs + + The default 75 character ``max_length`` is not capable of storing all + possible RFC3696/5321-compliant email addresses. In order to store all + possible valid email addresses, a ``max_length`` of 254 is required. + The default ``max_length`` of 75 exists for historical reasons. The + default has not been changed in order to maintain backwards + compatibility with existing uses of :class:`EmailField`. + ``FileField`` -------------