title: Django Rest Framework: Prevent duplicate objects when using CreateModelMixin
body: <p>I have a Viewset where a user can create reviews for a specific product and list their all the reviews they have created for all products:</p>
  
  <pre><code>class ProductReviewViewset(CreateModelMixin, ListModelMixin, GenericViewSet):
      serializer_class = ProductReviewSerializer
  
      def get_queryset(self):
          # Return all reviews for user that are not marked as deleted
          user = self.request.user
          return ProductReview.objects.filter(user=user, deleted=False).order_by('review__name')
  
      def perform_create(self, serializer):
          # Add user to review object before saving
          user = self.request.user
          serializer.save(user=self.request.user)
  </code></pre>
  
  <p>The problem is that this allows the user to create multiple reviews for the same object. I wanted to prevent this, and only allow to create a review if there is no other review already created for that product (reviews marked as "deleted" will not be counted).</p>
  
  <p>So far I was able to override the .create() method and do the serialization, validation and checking for duplicates in there.</p>
  
  <pre><code>class ProductReviewViewset(CreateModelMixin, ListModelMixin, GenericViewSet):
      serializer_class = ProductReviewSerializer
  
      def get_queryset(self):
          # Return all reviews for user that are not marked as deleted
          user = self.request.user
          return ProductReview.objects.filter(user=user, deleted=False).order_by('review__name')
  
      def create(self, request, *args, **kwargs):
          # Override create method to prevent duplicate object creation
          serializer = ProductReviewSerializer(data=self.request.data)
          serializer.is_valid(raise_exception=True)
          user = self.request.user
          product = serializer.validated_data['product']
          exists = ProductReview.objects.filter(user=user, product=product, deleted=False).exists()
          if not exists:
              serializer.save(user=user)
              return Response(status=status.HTTP_201_CREATED)
          else:
              return Response(status=status.HTTP_409_CONFLICT)
  </code></pre>
  
  <p>Is there an easier or better way of doing this? Or is this the way to do it?</p>
  
  <p>Thanks!</p>