title: How to return the last page when using pagination in django?
body: <p>In a simple forum, I'm using native django <a href="https://docs.djangoproject.com/en/1.8/topics/pagination/" rel="nofollow noreferrer">Pagination</a> I'd like users to be directed to the last page in a thread after they posted there.</p>
  
  <p>Here is the view</p>
  
  <pre><code>@login_required
  def topic_reply(request, topic_id):
      tform = PostForm()
      topic = Topic.objects.get(pk=topic_id)
      args = {}
      posts = Post.objects.filter(topic= topic)
      posts =  Paginator(posts,10)
  
  
      if request.method == 'POST':
          post = PostForm(request.POST)
  
  
          if post.is_valid():
              p = post.save(commit = False)
              p.topic = topic
              p.title = post.cleaned_data['title']
              p.body = post.cleaned_data['body']
              p.creator = request.user
  
              p.save()
  
              return HttpResponseRedirect('/forum/topic/%s/?page=%s'  % (topic.slug, posts.page_range[-1]))
  
      else:
          args.update(csrf(request))
          args['form'] = tform
          args['topic'] = topic
          return render_to_response('myforum/reply.html', args, 
                                    context_instance=RequestContext(request)) 
  </code></pre>
  
  <p>Which yields:</p>
  
  <pre><code>'Page' object has no attribute 'page_range'
  </code></pre>
  
  <p>I tried other tricks like:</p>
  
  <pre><code>posts = list(Post.objects.filter(topic= topic))
  </code></pre>
  
  <p>but none worked. So left clueless and appreciate your hints.</p>