diff options
| author | Aider Ibragimov | 2015-02-19 18:03:44 +0300 | 
|---|---|---|
| committer | Aider Ibragimov | 2015-02-19 18:03:44 +0300 | 
| commit | fe8d95f93e11d801d07c8852b12abb4f6b21e1e6 (patch) | |
| tree | 34ba73bbf5e094c4d71363c58ba29eafac79037f /rest_framework/validators.py | |
| parent | 3d85473edf847ba64aa499b336ca21f6b3d3c6b8 (diff) | |
| download | django-rest-framework-fe8d95f93e11d801d07c8852b12abb4f6b21e1e6.tar.bz2 | |
Skip validation of NULL field only if it part of unique_together
Diffstat (limited to 'rest_framework/validators.py')
| -rw-r--r-- | rest_framework/validators.py | 5 | 
1 files changed, 4 insertions, 1 deletions
| diff --git a/rest_framework/validators.py b/rest_framework/validators.py index c030abdb..ab361614 100644 --- a/rest_framework/validators.py +++ b/rest_framework/validators.py @@ -140,7 +140,10 @@ class UniqueTogetherValidator:          queryset = self.exclude_current_instance(attrs, queryset)          # Ignore validation if any field is None -        if None not in attrs.values() and queryset.exists(): +        checked_values = [ +            value for field, value in attrs.items() if field in self.fields +        ] +        if None not in checked_values and queryset.exists():              field_names = ', '.join(self.fields)              raise ValidationError(self.message.format(field_names=field_names)) | 
