Commit 5f4cc52e by Tom Christie

Tweaking

parent a58cfe16
...@@ -12,6 +12,9 @@ from rest_framework.utils.representation import smart_repr ...@@ -12,6 +12,9 @@ from rest_framework.utils.representation import smart_repr
class UniqueValidator: class UniqueValidator:
"""
Validator that corresponds to `unique=True` on a model field.
"""
# Validators with `requires_context` will have the field instance # Validators with `requires_context` will have the field instance
# passed to them when the field is instantiated. # passed to them when the field is instantiated.
requires_context = True requires_context = True
...@@ -46,6 +49,9 @@ class UniqueValidator: ...@@ -46,6 +49,9 @@ class UniqueValidator:
class UniqueTogetherValidator: class UniqueTogetherValidator:
"""
Validator that corresponds to `unique_together = (...)` on a model class.
"""
requires_context = True requires_context = True
message = _('The fields {field_names} must make a unique set.') message = _('The fields {field_names} must make a unique set.')
......
...@@ -131,7 +131,7 @@ class TestUniquenessTogetherValidation(TestCase): ...@@ -131,7 +131,7 @@ class TestUniquenessTogetherValidation(TestCase):
'position': 1 'position': 1
} }
def test_ignore_exlcuded_fields(self): def test_ignore_excluded_fields(self):
""" """
When model fields are not included in a serializer, then uniqueness When model fields are not included in a serializer, then uniqueness
validtors should not be added for that field. validtors should not be added for that field.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment