Make AjaxMessagesMiddleware Py3-compatible.