id summary reporter owner description type status component version severity resolution keywords cc stage has_patch needs_docs needs_tests needs_better_patch easy ui_ux
4604 session-based messages Sean Patrick Hogan tobias "Right now, in order to pass a message to the next view, you can use ""User.message_set.create('Your whatever has been saved successfully!')""
That works for logged-in users, but doesn't help users who aren't logged in and it's probably more complicated than it needs to be.
By contrast, we could store messages in the user's session. Every user (logged in or not) has a session that uniquely identifies them. By creating a request processor and middleware, we can make this process work for all users.
With the attached patch, you can put the FlashMiddleware into the middleware tuple and the Flash context processor into the tuple for context processors and then simply do: ""request.flash = 'Your whatever has been saved successfully!'
Since it runs off of the session data rather than the user data, it works without someone having to have logged in. This is very useful in many contexts. Also, I don't think we gain anything by storing it in the DB with a FK to User. Having it in the session just makes it nicely encapsulated to the browsing person.
**Flash is what Rails calls this functionality, but if someone wants to rename it to 'message', that's fine by me. request.message = 'Apple' might be easier for people to understand." Uncategorized closed Contrib apps master Normal fixed goliath.mailinglist@… real.human@… jshaffer2112@… pedro.lima@… tom@… andrewbadr.etc@… ashanks@… django@… ross@… semente@… egmanoj@… django@… grimdonkey@… robert.hopson@… viktor.nagy@… gonz@… oliver@… lemuelf@… dan.fairs@… hwaara@… siddhartag@… tonn81@… julian@… flosch@… daniel.tritone@… walter.php@… mikecampo@… Accepted 1 0 0 1 0