Ticket #16302: notes-update-comments-ip-address.patch

File notes-update-comments-ip-address.patch, 3.7 KB (added by Dan McGee, 13 years ago)

fix broken code found by changing field type, add release notes

  • docs/releases/1.4.txt

     
    341341a :class:`~django.db.models.fields.GenericIPAddressField` model field,
    342342a :class:`~django.forms.fields.GenericIPAddressField` form field and
    343343the validators :data:`~django.core.validators.validate_ipv46_address` and
    344 :data:`~django.core.validators.validate_ipv6_address`
     344:data:`~django.core.validators.validate_ipv6_address`.
    345345
     346The :class:`~django.contrib.comments.models.Comment` model formerly used a
     347:class:`~django.db.models.fields.IPAddressField` to store the ip_address of
     348comment submitters. This has been updated to use the new IPv4 and IPv6 capable
     349``GenericIPAddressField``. Unfortunately, the old type would silently truncate
     350IPv6 addresses longer than 15 characters for users of databases not having a
     351native IP address type (this does not apply to PostgreSQL). It is recommended
     352that users of the comments application resize the
     353``django_comments.ip_address`` column in affected databases to 39 characters.
     354
    346355Updated default project layout and ``manage.py``
    347356~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    348357
  • tests/modeltests/validation/models.py

     
    8888    generic_ip = models.GenericIPAddressField(blank=True, null=True, unique=True)
    8989    v4_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv4")
    9090    v6_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv6")
     91    ip_verbose_name = models.GenericIPAddressField("IP Address Verbose",
     92                        blank=True, null=True)
    9193
    9294class GenericIPAddrUnpackUniqueTest(models.Model):
    9395    generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True)
     
    102104        auto2 = models.AutoField(primary_key=True)
    103105except AssertionError, assertion_error:
    104106    pass # Fail silently
    105 assert str(assertion_error) == u"A model can't have more than one AutoField."
    106  No newline at end of file
     107assert str(assertion_error) == u"A model can't have more than one AutoField."
  • django/db/models/fields/__init__.py

     
    10101010    description = _("IP address")
    10111011    default_error_messages = {}
    10121012
    1013     def __init__(self, protocol='both', unpack_ipv4=False, *args, **kwargs):
     1013    def __init__(self, verbose_name=None, name=None, protocol='both',
     1014                 unpack_ipv4=False, *args, **kwargs):
    10141015        self.unpack_ipv4 = unpack_ipv4
    10151016        self.default_validators, invalid_error_message = \
    10161017            validators.ip_address_validators(protocol, unpack_ipv4)
  • django/contrib/comments/models.py

     
    5757
    5858    # Metadata about the comment
    5959    submit_date = models.DateTimeField(_('date/time submitted'), default=None)
    60     ip_address  = models.IPAddressField(_('IP address'), blank=True, null=True)
     60    ip_address  = models.GenericIPAddressField(_('IP address'),
     61                    unpack_ipv4=True, blank=True, null=True)
    6162    is_public   = models.BooleanField(_('is public'), default=True,
    6263                    help_text=_('Uncheck this box to make the comment effectively ' \
    6364                                'disappear from the site.'))
Back to Top