Ticket #16302: notes-update-comments-ip-address.patch
File notes-update-comments-ip-address.patch, 3.7 KB (added by , 13 years ago) |
---|
-
docs/releases/1.4.txt
341 341 a :class:`~django.db.models.fields.GenericIPAddressField` model field, 342 342 a :class:`~django.forms.fields.GenericIPAddressField` form field and 343 343 the 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`. 345 345 346 The :class:`~django.contrib.comments.models.Comment` model formerly used a 347 :class:`~django.db.models.fields.IPAddressField` to store the ip_address of 348 comment submitters. This has been updated to use the new IPv4 and IPv6 capable 349 ``GenericIPAddressField``. Unfortunately, the old type would silently truncate 350 IPv6 addresses longer than 15 characters for users of databases not having a 351 native IP address type (this does not apply to PostgreSQL). It is recommended 352 that users of the comments application resize the 353 ``django_comments.ip_address`` column in affected databases to 39 characters. 354 346 355 Updated default project layout and ``manage.py`` 347 356 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 348 357 -
tests/modeltests/validation/models.py
88 88 generic_ip = models.GenericIPAddressField(blank=True, null=True, unique=True) 89 89 v4_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv4") 90 90 v6_ip = models.GenericIPAddressField(blank=True, null=True, protocol="ipv6") 91 ip_verbose_name = models.GenericIPAddressField("IP Address Verbose", 92 blank=True, null=True) 91 93 92 94 class GenericIPAddrUnpackUniqueTest(models.Model): 93 95 generic_v4unpack_ip = models.GenericIPAddressField(blank=True, unique=True, unpack_ipv4=True) … … 102 104 auto2 = models.AutoField(primary_key=True) 103 105 except AssertionError, assertion_error: 104 106 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 107 assert str(assertion_error) == u"A model can't have more than one AutoField." -
django/db/models/fields/__init__.py
1010 1010 description = _("IP address") 1011 1011 default_error_messages = {} 1012 1012 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): 1014 1015 self.unpack_ipv4 = unpack_ipv4 1015 1016 self.default_validators, invalid_error_message = \ 1016 1017 validators.ip_address_validators(protocol, unpack_ipv4) -
django/contrib/comments/models.py
57 57 58 58 # Metadata about the comment 59 59 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) 61 62 is_public = models.BooleanField(_('is public'), default=True, 62 63 help_text=_('Uncheck this box to make the comment effectively ' \ 63 64 'disappear from the site.'))