Cool, thanks, I will try that!
On Apr 22, 12:19 am, Ayaz Ahmed Khan <a...@ayaz.pk> wrote:
> On 22-Apr-09, at 3:06 AM,Margiewrote:
>
> > Then in my html on the button that does the unlock I have something
> > like this:
>
> > <a href="{% url topic_unlock topic.id %}?next={% url post_list
> > topic.id %}"
>
> > I just thought maybe there was django magic that wouldn't require me
> > to pass in the "next" url.
>
> > Thanks for your insights!
>
> If you want to avoid passing in a value through the template, you
> could use boilerplate code such as the following in your view function
> to inspect the HTTP_REFERER value in the HttpRequest object and
> redirect or act accordingly:
>
> from urlparse import urlsplit
> referer = request.META.get('HTTP_REFERER', None)
> if referer is None:
> pass
> # do something here
> try:
> redirect_to = urlsplit(referer, 'http', False)[2]
> except IndexError:
> pass
> # do another thing here
> return HttpResponseRedirect(redirect_to)
>
> I have used something along the lines of that in view functions from
> which I wanted users to be taken back to the page they were on when
> they called the view.
>
> --
> Ayaz Ahmed Khan
>
> An evil mind is a great comfort.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---