You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using GenericIPAddressField with explicit protocol as IPv4 (Also reproduces with IPv6) and ModelSerializer. If the input is not an valid IpAddress, DRF generates duplicate(ish) errors.
Repro
fromdjango.dbimportmodelsfromrest_framework.serializersimportModelSerializerclassA(models.Model):
address=models.GenericIPAddressField(protocol="IPv4") # Also reproduces with `IPv6`classMeta:
app_label="main"classASerializer(ModelSerializer[A]):
classMeta:
model=Afields="__all__"ser=ASerializer(data={'address': 'not an ip address'})
ser.is_valid(raise_exception=True)
Result
rest_framework.exceptions.ValidationError: {'address': [
ErrorDetail(string='Enter a valid IPv4 address.', code='invalid'),
ErrorDetail(string='Enter a valid IPv4 or IPv6 address.', code='invalid')
]}
Hi!
I'm using
GenericIPAddressField
with explicitprotocol
asIPv4
(Also reproduces withIPv6
) andModelSerializer
. If the input is not an valid IpAddress, DRF generates duplicate(ish) errors.Repro
Result
The second error message is incorrect
Thanks!
The text was updated successfully, but these errors were encountered: