Skip to content

Commit b6c4d8c

Browse files
committed
Resolve duplicate error for IPAddressField. Closes encode#3250.
1 parent 0f77c27 commit b6c4d8c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

rest_framework/utils/field_mapping.py

+7
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ def get_field_kwargs(field_name, model_field):
185185
if validator is not validators.validate_slug
186186
]
187187

188+
# IPAddressField do not need to include the 'validate_ipv46_address' argument,
189+
if isinstance(model_field, models.GenericIPAddressField):
190+
validator_kwarg = [
191+
validator for validator in validator_kwarg
192+
if validator is not validators.validate_ipv46_address
193+
]
194+
188195
if getattr(model_field, 'unique', False):
189196
validator = UniqueValidator(queryset=model_field.model._default_manager)
190197
validator_kwarg.append(validator)

0 commit comments

Comments
 (0)