Cannot use add() on a ManyToManyField which specifies an intermediary model. Use .LikeTimestamp's Manager instead
<p>I'm trying to make a good like in my blog. Got problem, do not know how to use Manager here.
Guess this is my main mistake. Cannot use add() on a ManyToManyField which specifies an intermediary model. Use Posts.LikeTimestamp's Manager instead.</p>

<p><strong>my models:</strong></p>

<pre><code>class Like(models.Model):
    class Meta:
        db_table = 'like'
    post = models.OneToOneField(Post, null=True)
    liked_users = models.ManyToManyField(User, blank=True, through='LikeTimestamp')
    likes = models.IntegerField(default=0, blank=True)


class LikeTimestamp(models.Model):
    class Meta:
        db_table = 'liketimestamp'
    timestamp = models.DateTimeField(auto_now=True, auto_now_add=False)
    like = models.ForeignKey(Like)
    user = models.ForeignKey(User)
</code></pre>

<p><strong>my views:</strong></p>

<pre><code>@login_required
def like_post(request, comments_id):
    try:
        like, created = Like.objects.get_or_create(comments_id=comments_id)
        like.post = Post.objects.get(id=comments_id)
        if request.user in like.liked_users.all():
            like.liked_users.remove(request.user)
            like.likes -= 1
        else:
            like.liked_users.add(request.user)
            like.likes += 1
        like.save()
    except ObjectDoesNotExist:
        raise Http404
    return redirect(request.META.get('HTTP_REFERER'))
</code></pre>