Created
July 2, 2016 12:45
-
-
Save vaibhav-jain/91f49e8252ad4860b419868f704bbcf7 to your computer and use it in GitHub Desktop.
Django Rest Framework (DRF) Custom Unique Together Message
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
from django.utils.translation import ugettext_lazy as _ | |
from rest_framework import serializers | |
class SomeSerializer(serializers.ModelSerializer): | |
""" | |
Demostrating How to Override DRF UniqueTogetherValidator Message | |
""" | |
class Meta: | |
model = Some | |
validators = [ | |
serializers.UniqueTogetherValidator( | |
queryset=model.objects.all(), | |
fields=('field1', 'field2'), | |
message=_("Some custom message.") | |
) | |
] |
What if we want to check uniqueness based on lowercase character. can we do this in default validators or build own.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked for me as well.
Thanks a lot.