From 152035aee73ae9d218a347cc966a4b9a69f4ed44 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 16 Jul 2015 16:46:07 +0100 Subject: [PATCH] Cherry picks Upgrade guardian support to 1.3. #3165 --- rest_framework/filters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index c580f9351..2a05a8268 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -188,4 +188,7 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend): 'model_name': get_model_name(model_cls) } permission = self.perm_format % kwargs - return guardian.shortcuts.get_objects_for_user(user, permission, queryset) + if guardian.VERSION >= (1, 3): + # Maintain behavior compatibility with versions prior to 1.3 + extra = {'accept_global_perms': False} + return guardian.shortcuts.get_objects_for_user(user, permission, queryset, **extra)