From 3b3e3983e9f66d70c9c2232c2700e41c6a840314 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 22 Mar 2017 23:04:04 -0700 Subject: [PATCH] add none check for user If user never sign in, or there is no user in request. It throw exception. --- rest_framework/compat.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 45ac49841..3835095e9 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -128,6 +128,8 @@ def _resolve_model(obj): def is_authenticated(user): + if not user: + return False if django.VERSION < (1, 10): return user.is_authenticated() return user.is_authenticated