title: How to check if data already exists in the table using django
body: <p>I am new with django framework struggling to compare value from the database.
  this are my tables in models.py :</p>
  
  <pre><code>class Post(models.Model):
     user = models.ForeignKey(User, on_delete=models.CASCADE,)
     title = models.CharField(max_length=200)
     content = models.TextField()
     creationDate = models.DateTimeField(auto_now_add=True)
     lastEditDate = models.DateTimeField(auto_now=True)
  
     def __str__(self):
         return self.title
  
  class Votes(models.Model):
     user = models.ForeignKey(User, on_delete=models.CASCADE,)
     post_id = models.ForeignKey(Post, on_delete=models.CASCADE,)
     up_vote = models.PositiveIntegerField(default=0, validators=[MinValueValidator(0), MaxValueValidator(1)])
     down_vote = models.PositiveIntegerField(default=0, validators=[MinValueValidator(0), MaxValueValidator(1)])
  
     class Meta:
         unique_together = (("user","post_id"),) 
  </code></pre>
  
  <p>I have data in the vote tabe like this:
        <a href="https://i.stack.imgur.com/QEb75.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QEb75.png" alt="enter image description here"></a></p>
  
  <p>Now what I want is to check in the above table if 'user_id' and 'post_id' already exists in the Votes tabel's rows if the exist throw a message if not add value on upvote or downvote, i gues everyone understand what i want if not please let me know.</p>
  
  <p>something which i tried was this code:</p>
  
  <pre><code>def chk_table():
      user_id = request.user
      post_id = id
      votes_table = Votes.objects.filter(user_id=user_id, post_id= post_id).exists()
      return votes_table
  </code></pre>
  
  <p>but this function is checking in hole table not just in just in one row...</p>