mercredi 6 mai 2015

Show messages in Django

I am using Django's message framework.

When I have this view:

class ItemUpdateView(UpdateView):
    model = Item
    template_name = 'item_update_form.html'
    fields = ['name',]

    def dispatch(self, request, *args, **kwargs):
        messages.success(request, 'test')
        return super(ItemUpdateView, self).dispatch(request, *args, **kwargs)

    def form_valid(self, form):
        messages.success(self.request, "test")
        return super(ItemUpdateView, self).form_valid(form)

it does show a message from the dispatch method but if I'm updating the object, the message from form_valid wont be shown.

What can cause the code not to show the message from form_valid?

Aucun commentaire:

Enregistrer un commentaire