diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-06-11 13:48:24 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-06-11 13:48:24 +0000 |
| commit | ce3c281090320172d22e8a6057250d103c93438e (patch) | |
| tree | 11ed31f54ba1dae9873a6d215bbe74d77ac3216b /docs | |
| parent | 87571cdb3758458c2df61a1ff6a3a086797cafb6 (diff) | |
Fixed #811 -- Added support for IPv6 to forms and model fields. Many thanks to Erik Romijn.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16366 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/forms/fields.txt | 39 | ||||
| -rw-r--r-- | docs/ref/models/fields.txt | 32 | ||||
| -rw-r--r-- | docs/ref/validators.txt | 17 | ||||
| -rw-r--r-- | docs/releases/1.4.txt | 9 | ||||
| -rw-r--r-- | docs/topics/forms/modelforms.txt | 2 |
5 files changed, 99 insertions, 0 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt index 96f1be949b..3fc5b8aabf 100644 --- a/docs/ref/forms/fields.txt +++ b/docs/ref/forms/fields.txt @@ -622,6 +622,45 @@ Takes two optional arguments for validation: expression. * Error message keys: ``required``, ``invalid`` +``GenericIPAddressField`` +~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. class:: GenericIPAddressField(**kwargs) + +.. versionadded:: 1.4 + +A field containing either an IPv4 or an IPv6 address. + + * Default widget: ``TextInput`` + * Empty value: ``''`` (an empty string) + * Normalizes to: A Unicode object. IPv6 addresses are + normalized as described below. + * Validates that the given value is a valid IP address. + * Error message keys: ``required``, ``invalid`` + +The IPv6 address normalization follows `RFC4291 section 2.2`_, including using +the IPv4 format suggested in paragraph 3 of that section, like +``::ffff:192.0.2.0``. For example, ``2001:0::0:01`` would be normalized to +``2001::1``, and ``::ffff:0a0a:0a0a`` to ``::ffff:10.10.10.10``. All +characters are converted to lowercase. + +.. _RFC4291 section 2.2: http://tools.ietf.org/html/rfc4291#section-2.2 + +Takes two optional arguments: + +.. attribute:: GenericIPAddressField.protocol + + Limits valid inputs to the specified protocol. + Accepted values are ``both`` (default), ``IPv4`` + or ``IPv6``. Matching is case insensitive. + +.. attribute:: GenericIPAddressField.unpack_ipv4 + + Unpacks IPv4 mapped addresses like ``::ffff::192.0.2.1``. + If this option is enabled that address would be unpacked to + ``192.0.2.1``. Default is disabled. Can only be used + when ``protocol`` is set to ``'both'``. + ``MultipleChoiceField`` ~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 5c4bbd06bc..7765f2f8eb 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -760,6 +760,38 @@ single-line input). An IP address, in string format (e.g. "192.0.2.30"). The admin represents this as an ``<input type="text">`` (a single-line input). +``GenericIPAddressField`` +------------------------- + +.. class:: GenericIPAddressField([protocols=both, unpack_ipv4=False, **options]) + +.. versionadded:: 1.4 + +An IPv4 or IPv6 address, in string format (e.g. ``192.0.2.30`` or +``2a02:42fe::4``). The admin represents this as an ``<input type="text">`` +(a single-line input). + +The IPv6 address normalization follows `RFC4291 section 2.2`_, including using +the IPv4 format suggested in paragraph 3 of that section, like +``::ffff:192.0.2.0``. For example, ``2001:0::0:01`` would be normalized to +``2001::1``, and ``::ffff:0a0a:0a0a`` to ``::ffff:10.10.10.10``. All +characters are converted to lowercase. + +.. _RFC4291 section 2.2: http://tools.ietf.org/html/rfc4291#section-2.2 + +.. attribute:: GenericIPAddressField.protocol + + Limits valid inputs to the specified protocol. + Accepted values are ``'both'`` (default), ``'IPv4'`` + or ``'IPv6'``. Matching is case insensitive. + +.. attribute:: GenericIPAddressField.unpack_ipv4 + + Unpacks IPv4 mapped addresses like ``::ffff::192.0.2.1``. + If this option is enabled that address would be unpacked to + ``192.0.2.1``. Default is disabled. Can only be used + when ``protocol`` is set to ``'both'``. + ``NullBooleanField`` -------------------- diff --git a/docs/ref/validators.txt b/docs/ref/validators.txt index 0bb5abd819..0f299895c5 100644 --- a/docs/ref/validators.txt +++ b/docs/ref/validators.txt @@ -130,6 +130,23 @@ to, or in lieu of custom ``field.clean()`` methods. A :class:`RegexValidator` instance that ensures a value looks like an IPv4 address. +``validate_ipv6_address`` +------------------------- +.. versionadded:: 1.4 + +.. data:: validate_ipv6_address + + Uses :mod:`django.utils.ipv6` to check the validity of an IPv6 address. + +``validate_ipv46_address`` +-------------------------- +.. versionadded:: 1.4 + +.. data:: validate_ipv46_address + + Uses both ``validate_ipv4_address`` and ``validate_ipv6_address`` to + ensure a value is either a valid IPv4 or IPv6 address. + ``validate_comma_separated_integer_list`` ----------------------------------------- .. data:: validate_comma_separated_integer_list diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt index 90f925c02e..0fbcd34d77 100644 --- a/docs/releases/1.4.txt +++ b/docs/releases/1.4.txt @@ -155,6 +155,15 @@ You may override or customize the default filtering by writing a :ref:`custom filter<custom-error-reports>`. Learn more on :ref:`Filtering error reports<filtering-error-reports>`. +Extended IPv6 support +~~~~~~~~~~~~~~~~~~~~~ + +The previously added support for IPv6 addresses when using the runserver +management command in Django 1.3 has now been further extended by adding +a :class:`~django.db.models.fields.GenericIPAddressField` model field, +a :class:`~django.forms.fields.GenericIPAddressField` form field and +the validators :data:`~django.core.validators.validate_ipv46_address` and +:data:`~django.core.validators.validate_ipv6_address` Minor features ~~~~~~~~~~~~~~ diff --git a/docs/topics/forms/modelforms.txt b/docs/topics/forms/modelforms.txt index 6d418a22b9..031408a151 100644 --- a/docs/topics/forms/modelforms.txt +++ b/docs/topics/forms/modelforms.txt @@ -83,6 +83,8 @@ the full list of conversions: ``IPAddressField`` ``IPAddressField`` + ``GenericIPAddressField`` ``GenericIPAddressField`` + ``ManyToManyField`` ``ModelMultipleChoiceField`` (see below) |
