Just reading through the Django tutorial part four. One pattern from my own web-framework that didn't get covered is the "sessionMessage" tool. This is used when you submit a form via post, so you want to send the user to a new page, but you want to tell them what happened during the post (e.g. "Your order has been accepted").
The idea being that you can push messages via sessionMessage while working, then whether you render the page in the same request as the post (i.e. on an error condition) or via a redirect, your user gets the message. (Yes, there's the potential for messages showing up in a different browser window if you have some very-long-running requests, but it's never proven to be a problem, if they're switching that quickly they've still got the old page in mind when viewing the new page). In my site-wide templates there's code that displays the messages without any reference to what's being displayed, so there's no extra code required on an individual page to display the message. That lets you display messages from any page without worrying where the user will be when you're finished bouncing them around with redirects.
Ignoring how sessionMessage works in particular, I'd like to know whether there's a default mechanism for those kind of inter-page messages in Django (mostly because I had to write 2 or 3 ad-hoc ones earlier today, and that sucks).
Anyway, tired now. Work tomorrow.
Pingbacks are closed.