Posts Tagged ‘request’

Redirect to previous url after delete

Ever wondered how you can easily redirect a user to the previous url? I.e after a users clicks a delete link or some other action you can use the more common url.current() because that points to the delete action. Instead use request.header REFERER like this:
UPDATE: New way of doing this in pylons 1.0 as redirect_to is replaced by redirect. Thanks to DB for pointing that out!

(This is a Pylons example)

redirect(url(request.referer))

Done!