title: Prevent user liking own comments in Django API
body: <p>I'm hopeful someone can help with this problem. I believe the answer is probably straightfoward but it's eluding me. I'm creating a messaging API where users like comments, however, I want to prevent a user from liking their own comment</p>
  <p>I have the following Like model linking to a Message model:</p>
  <pre><code># models.py
  
  class Like(models.Model):
      message_id = models.ForeignKey(Message, related_name='message_id_like', on_delete=models.CASCADE)
      owner = models.ForeignKey(User, on_delete=models.CASCADE)
      like = models.BooleanField()
      like_date = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          return str(self.owner) + ', ' + self.message_id.message_title[:40]
  </code></pre>
  <p>With a serializer for the API</p>
  <pre><code># serializers.py
  
  class LikeSerializer(serializers.ModelSerializer):
      owner = serializers.ReadOnlyField(source='owner.username')
      class Meta:
          model = Like
          fields = [
              'message_id',
              'owner',
              'like',
              'like_date',
              ]
  </code></pre>
  <p>And a view:</p>
  <pre><code># views.py
  
  class LikeViewSet(viewsets.ModelViewSet): 
      queryset = Like.objects.all()
      serializer_class = LikeSerializer
  
      def perform_create(self, serializer): # Saving the user
          serializer.save(owner=self.request.user)
  </code></pre>
  <p>I believe I need an additional function within the LikeViewSet class that prevents the creation of a like when Like user matches Message user, however, I do not know how to specify it.</p>
  <p>Any help appreciated.</p>