diff --git a/django/utils/ipv6.py b/django/utils/ipv6.py
index 4f433d1..6e60959 100644
a
|
b
|
def clean_ipv6_address(ip_str, unpack_ipv4=False,
|
54 | 54 | |
55 | 55 | for index in range(len(hextets)): |
56 | 56 | # Remove leading zeroes |
57 | | hextets[index] = hextets[index].lstrip('0') |
| 57 | if "." not in hextets[index]: |
| 58 | hextets[index] = hextets[index].lstrip('0') |
58 | 59 | if not hextets[index]: |
59 | 60 | hextets[index] = '0' |
60 | 61 | |
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 70f039e..e444110 100644
a
|
b
|
class GenericIPAddressFieldTests(test.TestCase):
|
904 | 904 | with self.assertRaises(ValidationError): |
905 | 905 | form_field.clean('127.0.0.1') |
906 | 906 | |
| 907 | def test_mixed_ipv46(self): |
| 908 | """ |
| 909 | Test that GenericIPAddressField will accept a mixed IPv4 and IPv6 in all cases. See #26378. |
| 910 | """ |
| 911 | unpack_ip_field = models.GenericIPAddressField(null=False, protocol='both', unpack_ipv4=True) |
| 912 | not_unpack_ip_field = models.GenericIPAddressField(protocol='both', unpack_ipv4=False) |
| 913 | unpack_ip_field.clean('::ffff:0.0.0.0', None) |
| 914 | not_unpack_ip_field.clean('::ffff:0.0.0.0', None) |
| 915 | not_unpack_ip_field.clean('::ffff:0.255.255.255', None) |
| 916 | not_unpack_ip_field.clean('::ffff:1.0.0.0', None) |
| 917 | |
| 918 | |
907 | 919 | def test_null_value(self): |
908 | 920 | """ |
909 | 921 | Null values should be resolved to None in Python (#24078). |