From 80708e872e8cc6bf606afe7efdcec4b4d3e9866e Mon Sep 17 00:00:00 2001 From: Charlie Jacomme Date: Sat, 11 Aug 2018 04:14:13 +0200 Subject: [PATCH] Fix messages for usage in API --- re2o/context_processors.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/re2o/context_processors.py b/re2o/context_processors.py index 7cb965cc..6beac564 100644 --- a/re2o/context_processors.py +++ b/re2o/context_processors.py @@ -26,7 +26,7 @@ from __future__ import unicode_literals import datetime from django.contrib import messages - +from django.http import HttpRequest from preferences.models import GeneralOption, OptionalMachine from django.utils.translation import get_language @@ -40,7 +40,10 @@ def context_user(request): else: global_message = GeneralOption.get_cached_value('general_message_en') if global_message: - messages.warning(request, global_message) + if isinstance(request, HttpRequest): + messages.warning(request, global_message) + else: + messages.warning(request._request, global_message) if user.is_authenticated(): interfaces = user.user_interfaces() else: