On Mon, 2007-10-22 at 12:45 +0000, Rufman wrote:
> I'm displaying a large list of objects that are paginated by the
> Django Paginator. The list is rendered in a form, so that the user can
> limit the objects shown. The problem is that when I limit something I
> need to repaginate that result.
> 
> Now, for example if I come from page 5 and limit the output I need to
> set the viewed page back to 1, because there might not be a page 5 in
> the new selection, causing an invalidpage error. I can set this back
> without any problem. The only thing that's a bit ugly is the fact that
> in the url the page number 5 is still displayed. Even thought I
> changed the path variable in the request object before passing it the
> template.

OK, so if you're wanting to change the URL that the client is
retrieving, you need to use an HTTP redirect (return a
django.http.HttpResponseRedirect() class from your view). This sends the
new URL to retrieve back to the client, which then requests the new URL
and gets the new page. Hopefully your URLs contain enough information on
their own to describe what data is displayed on the page, because an
HTTP redirect is just the URL that should be retrieved.

Remember that the client's browser's URL line isn't just a visual thing.
It has real semantics. It shows the resource they requested, so it only
changes when they request a different resource.

Have a look at django.contrib.auth.views.redirect_to_login() if you want
an example of how to build a semi-complex URL for redirecting. There are
also examples of using redirects scattered through the documentation,
particularly in the forms documentation.

Regards,
Malcolm

-- 
No one is listening until you make a mistake. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to