mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 21:24:33 +03:00
Remove Django 1.5 URLValidator fallback
This commit is contained in:
parent
9216dc9a25
commit
e625cff8a5
|
@ -170,19 +170,6 @@ else:
|
||||||
super(MaxLengthValidator, self).__init__(*args, **kwargs)
|
super(MaxLengthValidator, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# URLValidator only accepts `message` in 1.6+
|
|
||||||
if django.VERSION >= (1, 6):
|
|
||||||
from django.core.validators import URLValidator
|
|
||||||
else:
|
|
||||||
from django.core.validators import URLValidator as DjangoURLValidator
|
|
||||||
|
|
||||||
|
|
||||||
class URLValidator(DjangoURLValidator):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.message = kwargs.pop('message', self.message)
|
|
||||||
super(URLValidator, self).__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
# PATCH method is not implemented by Django
|
# PATCH method is not implemented by Django
|
||||||
if 'patch' not in View.http_method_names:
|
if 'patch' not in View.http_method_names:
|
||||||
View.http_method_names = View.http_method_names + ['patch']
|
View.http_method_names = View.http_method_names + ['patch']
|
||||||
|
|
|
@ -11,7 +11,7 @@ import uuid
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ValidationError as DjangoValidationError
|
from django.core.exceptions import ValidationError as DjangoValidationError
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.core.validators import EmailValidator, RegexValidator, ip_address_validators
|
from django.core.validators import EmailValidator, RegexValidator, ip_address_validators, URLValidator
|
||||||
from django.forms import FilePathField as DjangoFilePathField
|
from django.forms import FilePathField as DjangoFilePathField
|
||||||
from django.forms import ImageField as DjangoImageField
|
from django.forms import ImageField as DjangoImageField
|
||||||
from django.utils import six, timezone
|
from django.utils import six, timezone
|
||||||
|
@ -24,7 +24,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||||
from rest_framework import ISO_8601
|
from rest_framework import ISO_8601
|
||||||
from rest_framework.compat import (
|
from rest_framework.compat import (
|
||||||
MaxLengthValidator, MaxValueValidator, MinLengthValidator,
|
MaxLengthValidator, MaxValueValidator, MinLengthValidator,
|
||||||
MinValueValidator, OrderedDict, URLValidator, duration_string,
|
MinValueValidator, OrderedDict, duration_string,
|
||||||
parse_duration, unicode_repr, unicode_to_repr
|
parse_duration, unicode_repr, unicode_to_repr
|
||||||
)
|
)
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
|
|
Loading…
Reference in New Issue
Block a user