flash messages #1725
Replies: 1 comment 1 reply
-
Off late "toast ui" is becoming a trend. Toast stays on the current page, and shows some sort of confirmation. This is useful when you can not show the effect on the current page (eg posting a tweet, you can show the timeline with tweet on top if you are on the right page). But if you are on a different page, where the end result can not show up, you have two options: a. same-page-toast, or b. redirect-and-message. The message framework is kind of for redirect and message. The django implementation, storing the message in the database, has one issue, that it can show up in the wrong place. Tho one can argue it is the right thing. Like if you confirmed your email on mobile, but say the next page did not load, so message is still in db, and you then open desktop, and you will see the message. This can be good, but only if the message you show has enough context, so user does not get confused. The other possibility is to store the "flash" message in the session store. We anyways do all our actions via the "action" way, where there is an ajax request, which returns redirect on success. This response can include the flash message, and our http.js can handle it in a generic way, by capture it and storing it in session store. With session store, the message will only show in the same tab where the action was carried out. |
Beta Was this translation helpful? Give feedback.
-
A port of this would be interesting: https://docs.djangoproject.com/en/5.0/ref/contrib/messages/
Beta Was this translation helpful? Give feedback.
All reactions