Commit 40a85043 authored by Tim Graham's avatar Tim Graham
Browse files

Fixed #23891 -- Moved deprecation of IPAddressField to system check framework.

Thanks Markus Holtermann for review.
parent a7aaabfa
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -334,6 +334,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
        command.execute(
            stdin=sentinel,
            stdout=six.StringIO(),
            stderr=six.StringIO(),
            interactive=False,
            verbosity=0,
            username='janet',
@@ -344,6 +345,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
        command = createsuperuser.Command()
        command.execute(
            stdout=six.StringIO(),
            stderr=six.StringIO(),
            interactive=False,
            verbosity=0,
            username='joe',
+13 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ from django import forms
from django.core import exceptions, validators, checks
from django.utils.datastructures import DictWrapper
from django.utils.dateparse import parse_date, parse_datetime, parse_time, parse_duration
from django.utils.deprecation import RemovedInDjango19Warning
from django.utils.duration import duration_string
from django.utils.functional import cached_property, curry, total_ordering, Promise
from django.utils.text import capfirst
@@ -1836,8 +1835,6 @@ class IPAddressField(Field):
    description = _("IPv4 address")

    def __init__(self, *args, **kwargs):
        warnings.warn("IPAddressField has been deprecated. Use GenericIPAddressField instead.",
                      RemovedInDjango19Warning)
        kwargs['max_length'] = 15
        super(IPAddressField, self).__init__(*args, **kwargs)

@@ -1860,6 +1857,19 @@ class IPAddressField(Field):
        defaults.update(kwargs)
        return super(IPAddressField, self).formfield(**defaults)

    def check(self, **kwargs):
        errors = super(IPAddressField, self).check(**kwargs)
        errors.append(
            checks.Warning(
                'IPAddressField has been deprecated. Support for it '
                '(except in historical migrations) will be removed in Django 1.9.',
                hint='Use GenericIPAddressField instead.',
                obj=self,
                id='fields.W900',
            )
        )
        return errors


class GenericIPAddressField(Field):
    empty_strings_allowed = True
+2 −1
Original line number Diff line number Diff line
@@ -159,7 +159,8 @@ details on these changes.
  is loaded. In particular, it won't be possible to import models inside
  the root package of their application.

* The model and form ``IPAddressField`` will be removed.
* The model and form ``IPAddressField`` will be removed. A stub field will
  remain for compatibility with historical migrations.

* ``AppCommand.handle_app()`` will no longer be supported.

+2 −0
Original line number Diff line number Diff line
@@ -95,6 +95,8 @@ Fields
* **fields.E160**: The options ``auto_now``, ``auto_now_add``, and ``default``
  are mutually exclusive. Only one of these options may be present.
* **fields.W161**: Fixed default value provided.
* **fields.W900**: ``IPAddressField`` has been deprecated. Support for it
  (except in historical migrations) will be removed in Django 1.9.

File Fields
~~~~~~~~~~~
+5 −0
Original line number Diff line number Diff line
@@ -192,3 +192,8 @@ Bugfixes

* Prevented a crash on apps without migrations when running ``migrate --list``
  (:ticket:`23366`).

* The deprecation of ``IPAddressField`` is now handled through the system
  check framework (with error code ``fields.W900``) so that deprecation
  warnings aren't displayed if the field only appears in historical migrations
  (:ticket:`23891`).
Loading