Performing AJAX requests with jQuery

Edit the images/image/detail.html template of the images application, and consider the following line:

{% with total_likes=image.users_like.count %}

Replace the preceding one with the following one:

{% with total_likes=image.users_like.count users_like=image.users_like.all %}

Then, modify the <div> element with the image-info class, as follows:

<div class="image-info">  <div>    <span class="count">      <span class="total">{{ total_likes }}</span>      like{{ total_likes|pluralize }}    </span>    <a href="#" data-id="{{ image.id }}" data-action="{% if      request.user in users_like %}un{% endif %}like"     class="like button">      {% if request.user not in users_like %}        Like      {% else %}        Unlike      {% endif %}    </a>  </div> {{ image.description|linebreaks ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.