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
{{ message }}
Repository navigation
Duplicated GenericIPAddressField validation errors with ModelSerializer and protocol #9645
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')
]}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
Daksh2000 commentedon Feb 9, 2025
Hi @HansAarneLiblik , Can I take this issue ?
HansAarneLiblik commentedon Feb 9, 2025
Sure, I don't mind!
Daksh2000 commentedon Feb 9, 2025
Hi @HansAarneLiblik ,
I have raised a PR , #9647
Please share your views on it.
NikeGunn commentedon Apr 26, 2025
stale commentedon Jul 19, 2025
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Fix duplicate validation errors for GenericIPAddressField with protoc…
Fix duplicate validation errors for GenericIPAddressField with protoc…