Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
django101
Commits
ddbc168d
Commit
ddbc168d
authored
Jun 04, 2024
by
Administrator
Browse files
added missing permission file
parent
23d86193
Changes
1
Hide whitespace changes
Inline
Side-by-side
my_app/permissions.py
0 → 100644
View file @
ddbc168d
from
rest_framework
import
permissions
class
CustomPermission
(
permissions
.
BasePermission
):
"""
Custom permission to only allow owners of an object to edit it.
"""
def
has_object_permission
(
self
,
request
,
view
,
obj
):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
if
request
.
method
in
permissions
.
SAFE_METHODS
:
return
True
# Write permissions are only allowed to the owner of the snippet.
return
request
.
user
!=
None
\ No newline at end of file
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