0

As a part of my error response I am trying to add "show" to a collapsable container using something like: class="{{request.session.registration}}" but instead of session use django messages so the "show" does not persist.

Right now I'm using a pretty janky workaround where I loop through all messages:

<form action = "registration" method = "POST" id="registration" 
    class="collapse container 
    {% for message in messages %}
        {% if 'registration' in message.tags%} 
        {{message}}
        {% endif %}
    {% endfor %} 
">

for reference, the message is added in the views.py via:

messages.info(request, 'show', extra_tags='registration')

How can I call this message explicitly?

Val14720
  • 45
  • 10
  • It could be possible by a custom template tag. I would personally rather push that into session scope and then remove it once consumed though. – Selcuk Aug 30 '18 at 04:50
  • Setting a context variable isnt an option? – Sachin Aug 30 '18 at 05:02
  • @SachinKukreja it might be .. are you suggesting to keep it as a message and **also** pass it in as context (only calling it as context)? – Val14720 Aug 30 '18 at 05:18
  • If you require it in `messages`, keep it. If you pass a boolean variable indicating to `show` or `hide` in the context, it will be better. – Sachin Aug 30 '18 at 05:26

0 Answers0