Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Open
Description
Hi!
I'm usingGenericIPAddressField
with explicitprotocol
asIPv4
(Also reproduces withIPv6
) andModelSerializer
. 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')]}
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.
Metadata
Metadata
Assignees
Labels
No labels