mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-04-25 11:33:43 +03:00
Resolve duplicate error for IPAddressField. Closes #3250.
This commit is contained in:
parent
0f77c27d34
commit
b6c4d8c25a
|
@ -185,6 +185,13 @@ def get_field_kwargs(field_name, model_field):
|
||||||
if validator is not validators.validate_slug
|
if validator is not validators.validate_slug
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# IPAddressField do not need to include the 'validate_ipv46_address' argument,
|
||||||
|
if isinstance(model_field, models.GenericIPAddressField):
|
||||||
|
validator_kwarg = [
|
||||||
|
validator for validator in validator_kwarg
|
||||||
|
if validator is not validators.validate_ipv46_address
|
||||||
|
]
|
||||||
|
|
||||||
if getattr(model_field, 'unique', False):
|
if getattr(model_field, 'unique', False):
|
||||||
validator = UniqueValidator(queryset=model_field.model._default_manager)
|
validator = UniqueValidator(queryset=model_field.model._default_manager)
|
||||||
validator_kwarg.append(validator)
|
validator_kwarg.append(validator)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user