Here is the banal code.

def func(request): messages.info(request, "Не покажется") return HttpResponseRedirect('/accounts/register/') def func_2(request): messages.info(request, "Все работает") return render_to_response('order.html', context_instance=RequestContext(request)) 

In def func_2, the page will appear, and the message “Everything Works” will appear. In def func, a redirect will occur, and no message will be displayed.

Tell me how to send messages with redirects?

In settings:

 MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage' TEMPLATE_CONTEXT_PROCESSORS = ( ... "django.contrib.messages.context_processors.messages") INSTALLED_APPS = ( ... 'django.contrib.messages',) 

    1 answer 1

    Should work.

    Write tests. Make sure the new entry is in the messages repository. Make sure that the messages from the messages are displayed on the registration page.

    Also check: in my opinion, the is_authenticated is a method, so it (not the result of its calling, but the method itself) is always not False.

    • The point is not is_authenticated. This was for example. Now I will simplify the code. The bottom line is that when the request is transmitted, then the message stretches, and if it is redirected, then apparently with a shortage, the request and message disappears. On all pages of the message are displayed, except for the pages on which there were redirects. That's interesting how to get around this. - trec
    • one
      I almost always use them with a redirect, and everything works. See what comes in the http 302 response browser. Perhaps FallbackStorage is to blame, and it’s worth choosing another one. - ravli 2:22 pm
    • Thanks for the hint. After all, for sure, my message is displayed via js and it was here that I did not initialize it. It all worked. He was so convinced that it was not possible and it was necessary to look for another method, which did not look trite for errors. - trec 2:58 pm