forked from encode/django-rest-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Case insensitive uniqueness validation (encode#4534)
- Loading branch information
1 parent
0b373be
commit 883efbc
Showing
3 changed files
with
6 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ class RelatedModel(models.Model): | |
|
||
class RelatedModelSerializer(serializers.ModelSerializer): | ||
username = serializers.CharField(source='user.username', | ||
validators=[UniqueValidator(queryset=UniquenessModel.objects.all())]) # NOQA | ||
validators=[UniqueValidator(queryset=UniquenessModel.objects.all(), lookup='iexact')]) # NOQA | ||
|
||
class Meta: | ||
model = RelatedModel | ||
|
@@ -103,7 +103,7 @@ def test_doesnt_pollute_model(self): | |
AnotherUniquenessModel._meta.get_field('code').validators, []) | ||
|
||
def test_related_model_is_unique(self): | ||
data = {'username': 'existing', 'email': '[email protected]'} | ||
data = {'username': 'Existing', 'email': '[email protected]'} | ||
rs = RelatedModelSerializer(data=data) | ||
self.assertFalse(rs.is_valid()) | ||
self.assertEqual(rs.errors, | ||
|