I'm trying to pass a dictionary through the "get_success_message" function but I just can't. I need more than a String on my message (title, color...) What am I doing wrong?
My view:
class PeliculasEdit(SuccessMessageMixin, UpdateView):
model = Pelicula
form_class = PeliculaForm
template_name = "videoclub/peliculas_edit.html"
success_url = reverse_lazy('peliculas_manage')
message_data = {
'color':'success',
'titulo':'Película editada',
'mensaje':'La película se ha editado correctamente',
}
def get_success_message(self, cleaned_data):
return self.message_data
My template where i'm using the message:
{% if messages %}
{% for message in messages %}
<div class="toast show" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
</div>
<div class="toast-body">
<p>{{message.color}}</p>
</div>
</div>
{% endfor %}
{% endif %}
I thought i had to {{message.color}} for example. But that's wrong. Thank you in advance!