Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
30bf9df5
Commit
30bf9df5
authored
Oct 21, 2016
by
Tom Christie
Committed by
GitHub
Oct 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix guardian import (#4612)
parent
0fe0e1e7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
rest_framework/compat.py
+0
-1
rest_framework/filters.py
+6
-1
No files found.
rest_framework/compat.py
View file @
30bf9df5
...
@@ -207,7 +207,6 @@ guardian = None
...
@@ -207,7 +207,6 @@ guardian = None
try
:
try
:
if
'guardian'
in
settings
.
INSTALLED_APPS
:
if
'guardian'
in
settings
.
INSTALLED_APPS
:
import
guardian
import
guardian
import
guardian.shortcuts
# Fixes #1624
except
ImportError
:
except
ImportError
:
pass
pass
...
...
rest_framework/filters.py
View file @
30bf9df5
...
@@ -289,6 +289,11 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
...
@@ -289,6 +289,11 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
perm_format
=
'
%(app_label)
s.view_
%(model_name)
s'
perm_format
=
'
%(app_label)
s.view_
%(model_name)
s'
def
filter_queryset
(
self
,
request
,
queryset
,
view
):
def
filter_queryset
(
self
,
request
,
queryset
,
view
):
# We want to defer this import until run-time, rather than import-time.
# See https://github.com/tomchristie/django-rest-framework/issues/4608
# (Also see #1624 for why we need to make this import explicitly)
from
guardian.shortcuts
import
get_objects_for_user
extra
=
{}
extra
=
{}
user
=
request
.
user
user
=
request
.
user
model_cls
=
queryset
.
model
model_cls
=
queryset
.
model
...
@@ -302,4 +307,4 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
...
@@ -302,4 +307,4 @@ class DjangoObjectPermissionsFilter(BaseFilterBackend):
extra
=
{
'accept_global_perms'
:
False
}
extra
=
{
'accept_global_perms'
:
False
}
else
:
else
:
extra
=
{}
extra
=
{}
return
g
uardian
.
shortcuts
.
g
et_objects_for_user
(
user
,
permission
,
queryset
,
**
extra
)
return
get_objects_for_user
(
user
,
permission
,
queryset
,
**
extra
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment