diff options
| author | Tom Christie | 2014-09-22 16:45:06 +0100 |
|---|---|---|
| committer | Tom Christie | 2014-09-22 16:45:06 +0100 |
| commit | e5f0a97595ff9280c7876fc917f6feb27b5ea95d (patch) | |
| tree | ad57f4bc221d92e34422517b947dc3c2d39b8ec3 /rest_framework/compat.py | |
| parent | 5586b6581d9d8db05276c08f2c6deffec04ade4f (diff) | |
| download | django-rest-framework-e5f0a97595ff9280c7876fc917f6feb27b5ea95d.tar.bz2 | |
More compat fixes
Diffstat (limited to 'rest_framework/compat.py')
| -rw-r--r-- | rest_framework/compat.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 2b4ddb02..7303c32a 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -139,6 +139,29 @@ else: self.message = kwargs.pop('message', self.message) super(MaxValueValidator, self).__init__(*args, **kwargs) +# URLValidator only accept `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) + + +# EmailValidator requires explicit regex prior to 1.6+ +if django.VERSION >= (1, 6): + from django.core.validators import EmailValidator +else: + from django.core.validators import EmailValidator as DjangoEmailValidator + from django.core.validators import email_re + + class EmailValidator(DjangoEmailValidator): + def __init__(self, *args, **kwargs): + super(EmailValidator, self).__init__(email_re, *args, **kwargs) + # PATCH method is not implemented by Django if 'patch' not in View.http_method_names: |
