This commit is contained in:
Christian Clauss 2023-12-10 08:49:32 +01:00
parent c11a7e6642
commit 1270ba903a
2 changed files with 5 additions and 2 deletions

View File

@ -17,7 +17,7 @@ jobs:
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
with: with:
python-version: "3.9" python-version: "3.11"
- uses: pre-commit/action@v3.0.0 - uses: pre-commit/action@v3.0.0
with: with:

View File

@ -9,6 +9,7 @@ import re
import uuid import uuid
from collections.abc import Mapping from collections.abc import Mapping
from enum import Enum from enum import Enum
from sys import version_info
from django.conf import settings from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
@ -866,7 +867,9 @@ class IPAddressField(CharField):
self.protocol = protocol.lower() self.protocol = protocol.lower()
self.unpack_ipv4 = (self.protocol == 'both') self.unpack_ipv4 = (self.protocol == 'both')
super().__init__(**kwargs) super().__init__(**kwargs)
validators, error_message = ip_address_validators(protocol, self.unpack_ipv4) validators = ip_address_validators(protocol, self.unpack_ipv4)
if version_info < (3, 12): # encode/django-rest-framework#9180
validators = validators[0] # Used to return a tuple: validators, error_message
self.validators.extend(validators) self.validators.extend(validators)
def to_internal_value(self, data): def to_internal_value(self, data):