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.
精彩评论