Python Post不是喜欢或不喜欢

Python Post不是喜欢或不喜欢,python,html,django,django-models,django-views,Python,Html,Django,Django Models,Django Views,我正在制作一个博客应用程序,我创建了一个“喜欢”或“不喜欢”的功能,但这不起作用。它显示自定义错误 detail.html <form method="GET" class="likeForm d-inline" action="{% url 'comments:post_like_dislike' post.id %}" data-pk="{{po

我正在制作一个博客应用程序,我创建了一个“喜欢”或“不喜欢”的功能,但这不起作用。它显示自定义错误

detail.html

                <form method="GET" class="likeForm d-inline" action="{% url 'comments:post_like_dislike' post.id %}"
                    data-pk="{{post.id}}">
                    <button type="submit" class="btn"><i class="far fa-thumbs-up"></i>
                        <span id="id_likes{{post.id}}">
                            {% if user in post.likes.all %}
                            <p style="color:#065FD4;display: inline">{{post.likes.count}}</p>
                            {% else %}
                            <p style="color:black;display: inline">{{post.likes.count}}</p>
                            {% endif %}
                        </span>
                        Like</button>
                </form>
                <form action="{% url 'comments:post_like_dislike' post.id %}" method="GET"
                    class="d-inline dislikeForm" data-pk="{{ post.id }}">
                    <button type="submit" class="btn"><i class="far fa-thumbs-down"></i>
                        <span id="id_dislikes{{post.id}}">
                            {% if user in post.dislikes.all %}
                            <p style="color:#065FD4; display: inline;">{{post.dislikes.count}}</p>
                            {% else %}
                            <p style="color:black; display: inline;">{{post.dislikes.count}}</p>
                            {% endif %}
                        </span>
                        Dislike
                    </button>
                </form>

{%if用户在post.likes.all%}

{{{post.likes.count}

{%else%}

{{post.likes.count}

{%endif%} 喜欢 {%if用户在post.dislikes.all%}

{{{post.dislikes.count}

{%else%}

{{post.dislikes.count}

{%endif%} 不喜欢
错误

当我点击“喜欢”按钮时,它会显示“出了问题(作为错误消息),但不计算喜欢的次数”。当我通过Admin单击like时,它会计数并显示在浏览器页面中。但当我手动点击Like按钮时就不会了

任何帮助都将不胜感激


提前感谢

您在提交表格时没有发送任何
喜欢
不喜欢
的信息。您应该在按钮中添加如下名称和值属性:

<form>
    <button name='submit' type='submit' value="like"> Like </button>
</form>
<form>
   <button name='submit' type='submit' value="dislike"> Dislike </button>
</form>

喜欢
不喜欢
仅供参考,在进行数据库更新时,最好使用
POST
方法。因为GET方法应该是幂等的,这意味着它们不应该更改服务器的状态

最后,由于有两种不同的形式,我认为最好有两种不同的视图来处理这些操作(一种表示喜欢,另一种表示不喜欢)