0

I'm trying to code a form in Django that redirect to itself, the display changing according to what you entered in the form. To do so, I retrieve the POST data in the backend and want to display a message this way: {% if message %} {{ message }} {% endif %} The problem is how to pass the message argument.

I know I could use

#urls.py
url(r'^form/(?P<message>)$', 'app.form', name='form')

#views.py
...my_message...
return HttpResponseRedirect(reverse('app:form', args=(my_message,))

but it would display the message in the url, which isn't suitable for my purpose. Would you know how I could do it and stay hidden in my backend, something like

#views.py
return HttpResponseRedirect(reverse('app:form'), {'message': my_message})
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Robin
  • 9,415
  • 3
  • 34
  • 45

1 Answers1

0

Use sessions to store the message - or even, the built-in messages framework.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Thank you for your answer ! I was trying to find a way to pass some kind of meta-data server side but if I understood well this isn't the way django works in this example. I'll investigate the sessions and message framework, thanks for the tip ! – Robin Apr 15 '13 at 22:00