From 87630bc3042da106b29fb1307bb77426f80dcf84 Mon Sep 17 00:00:00 2001 From: Curtis Maloney Date: Sat, 26 Sep 2015 20:03:42 -0400 Subject: [PATCH] Used getattr() to simplify contrib.messages.api. --- django/contrib/messages/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/contrib/messages/api.py b/django/contrib/messages/api.py index 8b6b96f96a..2566d71238 100644 --- a/django/contrib/messages/api.py +++ b/django/contrib/messages/api.py @@ -33,7 +33,7 @@ def get_messages(request): Returns the message storage on the request if it exists, otherwise returns an empty list. """ - return request._messages if hasattr(request, '_messages') else [] + return getattr(request, '_messages', []) def get_level(request): @@ -43,7 +43,7 @@ def get_level(request): The default level is the ``MESSAGE_LEVEL`` setting. If this is not found, the ``INFO`` level is used. """ - storage = request._messages if hasattr(request, '_messages') else default_storage(request) + storage = getattr(request, '_messages', default_storage(request)) return storage.level