mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 16:24:18 +03:00
Don't filter out the DecimalValidator if it is not supported
Previously, all validators set on a DecimalField in Django would be stripped when converted to a Django REST framework field. This was because any validator that was an instance of `DecimalValidator` would be removed, and when `DecimalValidator` wasn't supported (so it was `None`), all validators would be removed. This fixes the issue by only removing the `DecimalValidator` instances if the `DecimalValidator` is supported.
This commit is contained in:
parent
9bab640b0a
commit
87605e1e39
|
@ -130,7 +130,7 @@ def get_field_kwargs(field_name, model_field):
|
|||
|
||||
# Our decimal validation is handled in the field code, not validator code.
|
||||
# (In Django 1.9+ this differs from previous style)
|
||||
if isinstance(model_field, models.DecimalField):
|
||||
if isinstance(model_field, models.DecimalField) and DecimalValidator:
|
||||
validator_kwarg = [
|
||||
validator for validator in validator_kwarg
|
||||
if DecimalValidator and not isinstance(validator, DecimalValidator)
|
||||
|
|
Loading…
Reference in New Issue
Block a user