私のDjangoプロジェクトのようなボタンを実装しましたが、変更するには、ページ! 気に入った直後に嫌いなボタンを表示する方法とその逆?djangoのjsを使って "likeボタン"を切り替える方法
は、ここでは、コード
HTMLだ
<p>
<strong id="like_count">{{ post.likes }}</strong> people like this category
{% if user.is_authenticated %}
<button id="likes" data-post_id="{{post.id}}" class="btn btn-primary" type="button">
<span class="glyphicon glyphicon-thumbs-up"></span>
</button>
{% endif %}
</p>
JS
$('#likes').click(function(){
var postid;
postid= $(this).attr("data-post_id");
$.get('/blog/like_post/', {post_id: postid}, function(data){
$('#like_count').html(data);
$('#likes').hide();
});
});
$('#likes').click(function() {
$('#display_advance').toggle('1000');
$("i", this).toggleClass("glyphicon glyphicon-thumbs-down glyphicon glyphicon-thumbs-up");
});
は、私はあなたがに問題があると思う
これはDjangoと何が関係していますか? –
私はこれを私のdjangoプロジェクトで使用しています – Bharat