title: Ajax + Django Like button
body: <p>I have problems while I am building a simple like button. I have done everything as I have read in different tutorial but when I click on the Like button, it does not do anything. Look:</p>
  
  <p>models.py</p>
  
  <pre><code>class Comentario (models.Model):
      titulo = models.CharField(max_length=50)
      texto = models.CharField(max_length=200)
      autor = models.ForeignKey (Perfil, null=True, blank=True, on_delete=models.CASCADE)
      likes = models.IntegerField(default=0)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def like (request):
  
      com_id = None
  
      if request.method == 'GET':
          com_id = request.GET.get('comentario_id')
  
      likes = 0
      if com_id:
          com = Comentario.objects.get(id=int(com_id))
          if com:
              likes = com.likes + 1
              com.likes =  likes
              com.save()
      return HttpResponse(likes)
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>urlpatterns = [
      url(r'^like/$', login_required(views.like), name='like'),
  ]
  </code></pre>
  
  <p>.html</p>
  
  <pre><code>{% extends 'base/base.html' %}
  {% for comentario in objects %}
  ...
  {% if user.is_authenticated %}
              &lt;button id="likes" data-comid="{{comentario.id}}" class="btn btn-warning btn-sm " type="button"&gt;
              Like|&lt;strong id="like_count"&gt;{{ comentario.likes }}&lt;/strong&gt; 
              &lt;/button&gt;
  
  {% endif %}
  {% endfor %}    
  </code></pre>
  
  <p>js/ajax.js</p>
  
  <pre><code>$('#likes').click(function(){
      var comid;
      comid = $(this).attr("data-comid");
  $.get('/home/like/', {comentario_id: comid}, function(data){
            $('#like_count').html(data);
         $('#likes').hide();
      });
  });
  </code></pre>
  
  <p>And in base.html I have import all the .js</p>
  
  <p>base.html</p>
  
  <pre><code>        &lt;script src="{% static 'jq/jquery-3.2.1.min.js' %}"&gt;&lt;/script&gt;
          &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"&gt;&lt;/script&gt;
          &lt;script src= "{% static 'js/bootstrap.min.js' %}"&gt;&lt;/script&gt;
          &lt;script src= "{% static 'js/ajax.js' %}"&gt;&lt;/script&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The issue is that when I push the button nothing happens. It is a simple code but somethin crashes. In the inspection do not show any error or something missing.</p>
  
  <p>When I enter into .../home/like/ it appears a 0. </p>
  
  <p>I will appreciate your help.
  Thank you so much. </p>