diff options
| author | Tom Christie | 2014-10-22 13:30:28 +0100 | 
|---|---|---|
| committer | Tom Christie | 2014-10-22 13:30:28 +0100 | 
| commit | ae53fdff9c6bb3e81a1ec005134462f0d629688f (patch) | |
| tree | 3dc5590e7961491605b2009322f631af7ffbc01b /rest_framework/fields.py | |
| parent | c5d1be8eac6cdb5cce000ec7c55e1847bfcf2359 (diff) | |
| download | django-rest-framework-ae53fdff9c6bb3e81a1ec005134462f0d629688f.tar.bz2 | |
First pass at unique_for_date, unique_for_month, unique_for_year
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 10 | 
1 files changed, 8 insertions, 2 deletions
| diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 2da4aa8b..e939b2f2 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -268,11 +268,17 @@ class Field(object):          """          errors = []          for validator in self.validators: -            if getattr(validator, 'requires_context', False): -                validator.serializer_field = self +            if hasattr(validator, 'set_context'): +                validator.set_context(self) +              try:                  validator(value)              except ValidationError as exc: +                # If the validation error contains a mapping of fields to +                # errors then simply raise it immediately rather than +                # attempting to accumulate a list of errors. +                if isinstance(exc.detail, dict): +                    raise                  errors.extend(exc.detail)              except DjangoValidationError as exc:                  errors.extend(exc.messages) | 
