title: Django blog generate next/previous entries
body: <p>In a blog application (which I have mostly built following a tutorial), I would like to have a next and previous post link on the single page views of the posts.  The blog app's urls.py file looks like this:</p>
  
  <pre><code>from django.conf.urls.defaults import *
  from django.views.generic import list_detail
  from sandy.blog.models import Post
  
  
  urlpatterns = patterns('',
      url(r'^post/(?P&lt;slug&gt;.*)/$', list_detail.object_detail,
      {'queryset': Post.objects.all(), 'template_object_name': 'post',},
      name="single_post"),
      url(r'^$', list_detail.object_list,
      {'queryset': Post.objects.order_by('-published'), 'template_object_name': 'post',},
      name="blog_home"),
  </code></pre>
  
  <p>)</p>
  
  <p>In the single page template I would like to do something like this:</p>
  
  <pre><code>&lt;p&gt;&lt;a href="{% url single_post slug=[how would I derive it???] %}"&gt;Previous Post&lt;/a&gt;&lt;/p&gt;
  </code></pre>
  
  <p>I have the Post object as post available in the template, so I can do something like </p>
  
  <p>{% url single_post slug=post.slug %} for the current page, but would like to be able to do something like slug=post[-1].slug or whatever.  Is there a simple batteries included way to do this?</p>
  
  <p>Of course there would need to be some checking (to see if there is a previous post or not), and I would need to repeat it for the 'next post' link as well.</p>
  
  <p>I have been going around in circles to get this to work.  Is there a way, or am I forced to write out a full view for the page.</p>