Commit 87605e1e by Kevin Brown

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.
parent 9bab640b
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment