title: works when I use post_id, but as soon as I change to slug it doesn't work...why?
body: <p>I have a voting system I first coded without slug, but I decided to use slug for the post and the whole voting system does not work. I don't know why it doesn't work, it gives me 404error that indicates url is wrong but I'm pretty confident I set everything right. If you have any idea, I would appreciate it. Thank you.</p>
  
  <p>views.py</p>
  
  <pre><code>def index(request):
   try:
          sort = request.GET["sort"].strip()
          sort_method = SortMethods[sort]
          page = request.GET["page"].strip()
      except KeyError:
          sort_method = SortMethods.score
          page = 1
  
      if sort_method == SortMethods.date:
          thread_list = Post.objects.order_by("-pub_date")
      else:
          thread_list = Post.objects.all()
          thread_list = sorted(thread_list, key=lambda x: x.get_score(), reverse=True)
  
      paginator = Paginator(thread_list, 30)
  
      try:
          posts = paginator.page(page)
      except PageNotAnInteger:
          posts = paginator.page(1)
      except EmptyPage:
          posts = paginator.page(paginator.num_pages)
  
      context = {
          "posts": posts,
          "pages": paginator.page_range,
          "sort": sort_method.name
      }
      return render(request, "main/index.html", context)
  
  
  def vote(request, post_id): #here I switch to slug
  try:
          error_message = "Not a valid request"
          is_up = int(request.GET["is_up"].strip())
          if is_up == 1 or is_up == 0:
              if not request.user.is_authenticated():
                  error_message = "please login"
              else:
                  post = get_object_or_404(Post, id=post_id) #I switch to slug=slug
                  try:
                      vote = post.vote_set.get(user=request.user)
                  except Vote.DoesNotExist:
                      post.vote_set.create(user=request.user, is_up=is_up)
                  else:
                      if vote.is_up == is_up:
                          vote.delete()
                      else:
                          vote.is_up = is_up
                          vote.save()
  
                  json_data = '{"count":"%s"}' % post.get_vote_count()
                  return HttpResponse(json_data, content_type="application/json; charset=utf-8")
      except KeyError:
          json_data = '{"error_message":"%s"}' % "Not a valid request"
          return HttpResponseBadRequest(json_data, content_type="application/json; charset=utf-8")
      else:
          json_data = '{"error_message":"%s"}' % error_message
          return HttpResponseBadRequest(json_data, content_type="application/json; charset=utf-8")
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>  url(r'^post/(?P&lt;post_id&gt;\d+)/vote/$', 'main.views.vote', name='vote'), #I switch to ?P&lt;slug&gt;\d+
      url(r'^(?P&lt;post_id&gt;[\w|\-]+)/$', views.post, name='post'),
  # I switch to ?P&lt;slug&gt;
  </code></pre>
  
  <p>my index.html</p>
  
  <pre><code>&lt;table class="table"&gt;
      {% if posts %}
          {% for post in posts %}
          &lt;tr&gt;
              &lt;td class="vert-align"&gt;&lt;div&gt;
                              &lt;a href="/post/{{ post.id }}/vote?is_up=1" class="vote"&gt; #I switch to post.slug for every post.id 
  
                      &lt;span class="glyphicon glyphicon-chevron-up" aria-hidden="true"&gt;&lt;/span&gt;&lt;/a&gt;
                  &lt;br&gt;
                  &lt;a href="/post/{{ post.id }}/vote?is_up=0"  class="vote"&gt;
                      &lt;span class="glyphicon glyphicon-chevron-down" aria-hidden="true"&gt;&lt;/span&gt;&lt;/a&gt;
              &lt;/div&gt;&lt;/td&gt;
              &lt;td class="vert-align"&gt;
                  &lt;h4 id="vote_count_{{ post.id }}"&gt;{{ post.get_vote_count }}&lt;/h4&gt;
              &lt;/td&gt;
              &lt;td&gt;
                  &lt;h4&gt;&lt;a href="{% url 'post' post.id %}"&gt;{{ post.title }}&lt;/a&gt;&lt;/h4&gt;
                  &lt;ol class="breadcrumb"&gt;
                      &lt;li&gt;&lt;span&gt;{{ post.moderator.username }}&lt;/span&gt;&lt;/li&gt;
                      &lt;li&gt;&lt;span class="time_presentation"&gt;{{ post.pub_date | date }}&lt;/span&gt;&lt;/li&gt;
                  &lt;/ol&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          {% endfor %}
  </code></pre>
  
  <p>Then I get 404 error. any thoughts would be appreciated. </p>