title: "Like" counter, increment value by click in django
body: <p>Im trying to make simple button that will increament my value by 1 in database and show it on page.</p>
  
  <p>I found something on <a href="https://stackoverflow.com/questions/16431822/django-how-to-increment-integer-field-from-user-input">Django - How to increment integer field from user input?</a> but it doesn't solve problem.</p>
  
  <p>My code in views.py:</p>
  
  <pre><code>if request.method == 'POST':
      id = request.POST.get('slug')
      vote = request.POST.get('voo')
      glosy = request.POST.get('glosy')
      git = Photo.objects.all().filter(pk=id, votes = vote)
      vote = int(vote)+1
  
  
      p = Photo.objects.get(pk=id)
      print p.votes3
      p.votes3 += 1
      print p.votes3
      p.save()
  
      Photo.objects.all().filter(pk=id).update(votes3=10)
  </code></pre>
  
  <p>and my code in template:</p>
  
  <pre><code>{% extends "photologue/root.html" %}
  
  {% load photologue_tags i18n %}
  {% load comments %}
  
  {% block title %}{{ obj.title }}{% endblock %}
  
  {% block content %}
  
  {% load static %}
  
    &lt;script src="{% static 'js/pinol-ajax.js' %}"&gt;&lt;/script&gt;
  &lt;script&gt;
  
    window.fbAsyncInit = function() {
      FB.init({
        appId      : '876940702346526',
        xfbml      : true,
        version    : 'v2.2'
      });
    };
  
    (function(d, s, id){
       var js, fjs = d.getElementsByTagName(s)[0];
       if (d.getElementById(id)) {return;}
       js = d.createElement(s); js.id = id;
       js.src = "//connect.facebook.net/en_US/sdk.js";
       fjs.parentNode.insertBefore(js, fjs);
     }(document, 'script', 'facebook-jssdk'));
  &lt;/script&gt;
  
      &lt;div class="row col-lg-12"&gt;
          &lt;h1 class="page-header"&gt;{{ obj.title }}&lt;/h1&gt;
          &lt;p class="muted"&gt;&lt;small&gt;{% trans "Published" %} {{ obj.date_added }}&lt;/small&gt;&lt;/p&gt;
      &lt;/div&gt;
  
      &lt;div class="row"&gt;
          &lt;div class="col-md-6"&gt;
              {% if obj.caption %}&lt;p&gt;{{ obj.caption|safe }}&lt;/p&gt;{% endif %}
                &lt;a href="{{pho.image.url}}" data-lightbox="roadtrip" alt = ""&gt;
                  &lt;img src="{{ pho.get_display_url }}" class="thumbnail" alt="{{ obj.title }}"&gt;&lt;/a&gt;
  
  
  &lt;br&gt;        
  &lt;!-- &lt;button id="likes" data-catid="{{obj.title}}" class="btn btn-primary" type="button"&gt; Like  &lt;/button&gt; {{ pho.votes }}  {{ object.view_count }} --&gt; 
  &lt;strong id="like_count"&gt;{{ pho.votes }}&lt;/strong&gt; people like this photo
  
  {% if user.is_authenticated %}
  &lt;form action="" method="post"&gt;
    {% csrf_token %}
        &lt;button type="submit" value="preview" name="Preview"&gt;HUEHUE&lt;/button&gt; 
  
  {% endif %}            
  &lt;div class="fb-share-button"  data-layout="button_count"&gt;&lt;/div&gt;
  
              &lt;/a&gt;
          &lt;/div&gt;
          &lt;div class="col-md-6"&gt;
              {% if pho.public_galleries %}
                  &lt;p&gt;{% trans "This photo is found in the following galleries" %}:&lt;/p&gt;
                  &lt;table&gt;
                      {% for gallery in pho.public_galleries %}
                          &lt;tr&gt;
                              &lt;td&gt;{% previous_in_gallery pho gallery %}&lt;/td&gt;
                              &lt;td class="text-center"&gt;&lt;a href=""&gt;{{ gallery.title }}&lt;/a&gt;&lt;/td&gt;
                              &lt;td&gt;{% next_in_gallery pho gallery %}&lt;/td&gt;
                          &lt;/tr&gt;
                      {% endfor %}
                  &lt;/table&gt;
  
  &lt;link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}fluent_comments/css/ajaxcomments.css" /&gt;
  &lt;script type="text/javascript" src="{{ STATIC_URL }}fluent_comments/js/ajaxcomments.js"&gt;&lt;/script&gt;
  
  &lt;div class="fb-like" data-href="{{request.META.HTTP_HOST}}" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"&gt;&lt;/div&gt;
  &lt;div class="fb-comments" data-href="{{request.META.HTTP_HOST}}" data-numposts="5" data-colorscheme="light"&gt;&lt;/div&gt;
  &lt;!-- {{request.META.HTTP_HOST}}{{request.get_full_path}} --&gt;
  {% render_comment_list for pho %}
  
  {% if user.is_authenticated %}
      {% render_comment_form for pho %}
  {% else %}
      Zaloguj się aby dodawać komentarze! :)
  {% endif %}
  
  
              {% endif %}
  
  
  {% endblock %}
  </code></pre>