Hi, I have been wondering doesn't DRF convert Django's ValidationError
raised from `validate_unique` or from `clean` method of the model?
I have ModelViewSet:
```python
class UpvoteViewSet(ModelViewSet):
queryset = Upvote.objects.all()
serializer_class = UpvoteSerializer
```
and I have added `validate_unique` method to model:
```python
def validate_unique(self, *args, **kwargs):
super().validate_unique(*args, **kwargs)
upvote_model = self.__class__
if upvote_model.objects.filter(upvoted_item=self.upvoted_item,
upvoted_user=self.upvoted_user).exists():
raise ValidationError(['This user already upvoted this item.',
])
```
The problem is `ValidationError` is from Django and if I use DRF's
ValidationError then I get an error in Django Admin. So, what's happening.
Does DRF handle this??
--
You received this message because you are subscribed to the Google Groups
"Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-rest-framework/873ecf8a-ffd9-459b-b271-d78d05633684o%40googlegroups.com.