This sadly wouldn't work. But if I change redirect('accounts:login') to render(request, 'accounts/login.html'), the message would display.
I can't reproduce the issue given the details you provided. Ideally, you could debug the problem enough to explain why Django is at fault. If you can't do that, you can ask for help in confirming the bug using our support channels. Please reopen with a minimal project that reproduces the issue if a bug is confirmed. Thanks!
Thank you, Tim Graham. Your confirmation helped me look at other places and found that the session cookie's domain setting was the problem. So obviously the production setting was failing while developing on localhost.