Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
5f4cc52e
Commit
5f4cc52e
authored
Oct 09, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweaking
parent
a58cfe16
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
1 deletions
+7
-1
rest_framework/validators.py
+6
-0
tests/test_validators.py
+1
-1
No files found.
rest_framework/validators.py
View file @
5f4cc52e
...
@@ -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.'
)
...
...
tests/test_validators.py
View file @
5f4cc52e
...
@@ -131,7 +131,7 @@ class TestUniquenessTogetherValidation(TestCase):
...
@@ -131,7 +131,7 @@ class TestUniquenessTogetherValidation(TestCase):
'position'
:
1
'position'
:
1
}
}
def
test_ignore_ex
lc
uded_fields
(
self
):
def
test_ignore_ex
cl
uded_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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment