开发者

django: search forms and redirect

开发者 https://www.devze.com 2022-12-23 18:35 出处:网络
After processing form from POST I should redirect, to prevent user from hitting back. However, I am using form to determine search query on a database, so I need to either pass params to the redirecte

After processing form from POST I should redirect, to prevent user from hitting back. However, I am using form to determine search query on a database, so I need to either pass params to the redirected site or the result of a search. Or maybe there is some other good practice, how to solv开发者_JAVA百科e this problem? Maybe in this situation I am allowed not to redirect (nothing happens, if user performs search again).


Search queries should probably be GETs, rather than POSTs, because they are not changing anything - they are simply passing parameters to get certain information. POST should be reserved for forms that actually change things in the database, or result in a specific action (eg submitting an email).

To reply to your comment, hiding parameters from URLs is not particularly good practice, but if you really think you need to, this is an instance where it's OK not to redirect after the form submission - again, because you're not affecting anything with the POST.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号