mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 12:30:11 +03:00
Remove DecimalValidator compat
This commit is contained in:
parent
0d78453fa5
commit
74c995ca16
|
@ -277,12 +277,6 @@ else:
|
||||||
LONG_SEPARATORS = (b', ', b': ')
|
LONG_SEPARATORS = (b', ', b': ')
|
||||||
INDENT_SEPARATORS = (b',', b': ')
|
INDENT_SEPARATORS = (b',', b': ')
|
||||||
|
|
||||||
# TODO: Remove
|
|
||||||
try:
|
|
||||||
# DecimalValidator is unavailable in Django < 1.9
|
|
||||||
from django.core.validators import DecimalValidator
|
|
||||||
except ImportError:
|
|
||||||
DecimalValidator = None
|
|
||||||
|
|
||||||
class CustomValidatorMessage(object):
|
class CustomValidatorMessage(object):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.core import validators
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.text import capfirst
|
from django.utils.text import capfirst
|
||||||
|
|
||||||
from rest_framework.compat import DecimalValidator, postgres_fields
|
from rest_framework.compat import postgres_fields
|
||||||
from rest_framework.validators import UniqueValidator
|
from rest_framework.validators import UniqueValidator
|
||||||
|
|
||||||
NUMERIC_FIELD_TYPES = (
|
NUMERIC_FIELD_TYPES = (
|
||||||
|
@ -181,11 +181,10 @@ def get_field_kwargs(field_name, model_field):
|
||||||
if validator is not validators.validate_ipv46_address
|
if validator is not validators.validate_ipv46_address
|
||||||
]
|
]
|
||||||
# Our decimal validation is handled in the field code, not validator code.
|
# 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_kwarg = [
|
||||||
validator for validator in validator_kwarg
|
validator for validator in validator_kwarg
|
||||||
if not isinstance(validator, DecimalValidator)
|
if not isinstance(validator, validators.DecimalValidator)
|
||||||
]
|
]
|
||||||
|
|
||||||
# Ensure that max_length is passed explicitly as a keyword arg,
|
# Ensure that max_length is passed explicitly as a keyword arg,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user