Using messages.
options = { 'section': 'contact', 'message': "You've successfully posted"}
messages.add_message(self.request, messages.SUCCESS, options)
{% for message in messages %}
<p{% if message.tags %} class="{{ message.tags }}"{% endif %}>
{{ message.section }} - {{ message.message }}
</p>
{% endfor %}
The only solution I could think of is the render the data in JavaScript :
{% for message in messages %}
<script>
let options = {{ message | safe }};
console.log(options);
</script>
{% endfor %}
Or, you could create your own messaging framework by inheriting the existing classes and extending the library, middleware and context processor to meet your needs.