-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Open
Labels
Description
Hi!
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
from django.db import models
from rest_framework.serializers import ModelSerializer
class A(models.Model):
address = models.GenericIPAddressField(protocol="IPv4") # Also reproduces with `IPv6`
class Meta:
app_label = "main"
class ASerializer(ModelSerializer[A]):
class Meta:
model = A
fields = "__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')
]}The second error message is incorrect
Thanks!
- Raised initially as discussion - Can't, it gets deleted automatically - https://groups.google.com/g/django-rest-framework/c/eNNq1UYeww4
- This is not a feature request suitable for implementation outside this project. Please elaborate what it is:
- other type of bug fix
- I have reduced the issue to the simplest possible case.