Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Duplicated GenericIPAddressField validation errors with ModelSerializer and protocol #9645

Open
@HansAarneLiblik

Description

@HansAarneLiblik

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp