• Как сделать систему лайков в Django?

    Robertgoodman
    @Robertgoodman
    serhiops,

    <form method="post" action="{% url 'like' video.pk %}">
                  {% csrf_token %}
                  <div style="margin-top: 10px; width: 30px; height: 30px; margin-left: 950px;">
                      <input type="hidden" name="text" value="{{ request.path }}">
                      <button style="background: transparent; border: none; box-shadow: none;" type="submit">
                          <img src="{% static 'images/like.png' %}">
                          <span>{{ video.likes.all.count }}</span>
                      </button>
                  </div>
    
              </form>
    
    
               <form method="post" action="{% url 'dislike' video.pk %}">
                  {% csrf_token %}
                  <div style="margin-top: -30px; width: 30px; height: 30px; margin-left: 980px;">
                      <input type="hidden" name="text" value="{{ request.path }}">
                      <button style="background: transparent; border: none; box-shadow: none;" type="submit">
                         <img src="{% static 'images/dislike.png' %}">
                          <span>{{ video.dislikes.all.count }}</span>
                      </button>
                  </div>
               </form>