开发者

Django: How to display errors in a custom action?

What's the best practice for displaying an error message for erro开发者_JS百科rs that occurred in a custom action?


Use messages framework. The description is here

in custom action you just use

messages.info(request, 'Message')


add an error message to the contrib messages app? It will be displayed at the top of the page on next request/ next page the user sees. Be sure to set the message type as error. Also, be sure to run the action in a transaction and roll it back on error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜