How to pass information using an HTTP redirect (in Django)

后端 未结 11 884
北恋
北恋 2021-02-01 19:22

I have a view that accepts a form submission and updates a model.

After updating the model, I want to redirect to another page, and I want a message such as \"Field X su

11条回答
  •  佛祖请我去吃肉
    2021-02-01 20:23

    While all suggestions so far work, I would suggest going with Ry4an's (pass it in the request URL) - just change the actual text to a coded text within a predefined set of text messages.

    Two advantages here:

    1. Less chance of something hacking through your scrubbing of bad content
    2. You can localize your messages later if needed.

    The other cookie related methods.. well, they don't work if the browser doesn't support cookies, and are slightly more expensive.. But only slightly. They're indeed cleaner to the eye.

提交回复
热议问题