title: "Next" and "Previous" button on Django, on posts with Slugs
body: <p>What I want is to create "Next Post" and "Previous Post" on Django. What I have managed to do until now is to link the button to a page where the primary key is one above or one below the current post:</p>
  
  <pre><code>&lt;a class="btn btn-default" href="{% url 'post_detail' slug=post.slug pk=post.pk|add:'1' %}"&gt;Next&lt;/a&gt;
  </code></pre>
  
  <p>There are two issues: one is with the Slug and with the URL, and the other is with the showing (or hiding) of the button.</p>
  
  <p>When I click next, I am taken to the next post (if it exists. If it doens't I receive an error telling me that such a page doesn't exist). The URL remains the same as the previous post, correspondingly: If I click it three times, the URL displayed will be the one of the second post. What I would like is to somehow also display the corresponding slug.</p>
  
  <p>The second problem, is that I want to disable the button if there is no post before or after. But the following piece of code:</p>
  
  <pre><code>  {% if post.pk|add:'1' %}
  </code></pre>
  
  <p>Which is what I have come up with up until now. But apparently it checks if such a number exists, not if the post exists or not.</p>
  
  <p>The view class for this page is the following:</p>
  
  <pre><code>class PostDetailView(HitCountDetailView):
      model = Post
      slug_field = "title"
      count_hit = True
  </code></pre>
  
  <p>Whereas the model is (removing irrelevant-to-this-issue code):</p>
  
  <pre><code>@python_2_unicode_compatible
  class Post(models.Model, HitCountMixin):
      author = models.ForeignKey('auth.User')
      title = models.CharField(max_length=100, null=False, blank=False)
      text = models.TextField(null=False, blank=False)
      slug = models.SlugField(max_length=100, blank=True)
  
      # rewrite save method
      def save(self, *args, **kwargs):
          if not self.id:
              self.slug = slugify(self.title)
          super(Post, self).save(*args, **kwargs)
  
      def article_pre_save(signal, instance, sender, **kwargs):
          instance.slug = slugify(instance.title)
  
      signals.pre_save.connect(article_pre_save, sender="blog.Post")
  
      # go to post page 
      def get_absolute_url(self):
          return reverse("post_detail", kwargs={'slug':self.slug, 'pk':self.pk})
  
      # retorna o título do post
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>And the related url:</p>
  
  <pre><code>    url(_(r'^post/(?P&lt;pk&gt;\d+)-(?P&lt;slug&gt;[-\w]+)/$'), views.PostDetailView.as_view(), name='post_detail'),
  </code></pre>
  
  <p>How could I proceed to this? I thought about writing a Raw SQL query (I've been having problems with this too, but that's another matter), but I don't know, up to now, how I could actually link it to the  template. Thank you for your help, if you will, and attention, in advance.</p>