From 03411ac9bd4cca1444c748ac2136ea2997cb20c1 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 8 Sep 2021 16:59:44 +0200 Subject: [PATCH] Don't check permissions in a script Signed-off-by: Yohann D'ANELLO --- apps/permission/backends.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/permission/backends.py b/apps/permission/backends.py index af071455..f9c90d56 100644 --- a/apps/permission/backends.py +++ b/apps/permission/backends.py @@ -159,6 +159,10 @@ class PermissionBackend(ModelBackend): primary key, the result is not memoized. Moreover, the right could change (e.g. for a transaction, the balance of the user could change) """ + # Requested by a shell + if request is None: + return False + user_obj = request.user sess = request.session