How to keep django messages alive (in the django admin), until they are deleted by a further action?
I use the django messages to remind the user of a required activity. The message should displayed until the required activity is done.
For one view, I renew the message every time the change_view is called. But I don't think this is a solution for the whole django-admin.
admin.py
class InvitationAdmin(admin.ModelAdmin):
def change_view(self, request, object_id, form_url='', extra_context=None):
# keep massages alive
answerSubQuestions = request.session.get('answerSubQuestions')
#add massages
if answerSubQuestions:
for answerid in answerSubQuestions:
answer = Answer.objects.get(pk=answerid)
messages.warning(request, mark_safe('<p style="float:left;line-height:29px;margin-right:15px;">Please add answer for subquestion: </p><a href="%s" class="actionButton actionButtonBlue grp-button" onclick="return showAddAnotherPopup(this);">click here!</a>'%reverse('changeAnswer', args=[answer.id,answer.question.getQuestionType()])))
return super(InvitationAdmin, self).change_view(request, object_id, form_url, extra_context=extra_context)
I would like to have something like:
messages.warning(request, mark_safe('Message'), keepalive=True)