From 788aae2aaf9f0bd8cfdce167b24222c47e72ef99 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Thu, 16 Jul 2015 16:46:07 +0100 Subject: [PATCH] Upgrade guardian support to 1.3. Closes #3163. --- requirements/requirements-optionals.txt | 2 +- rest_framework/filters.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/requirements/requirements-optionals.txt b/requirements/requirements-optionals.txt index 411ca0aab..3ada43ebd 100644 --- a/requirements/requirements-optionals.txt +++ b/requirements/requirements-optionals.txt @@ -1,4 +1,4 @@ # Optional packages which may be used with REST framework. markdown==2.5.2 -django-guardian==1.2.5 +django-guardian==1.3.0 django-filter==0.10.0 diff --git a/rest_framework/filters.py b/rest_framework/filters.py index 36ce00476..a5e06b574 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -198,4 +198,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)