This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.exceptions import PermissionDenied | |
from django.apps import apps | |
def is_owner_permission(model=None, url_field='pk', model_field="owner"): | |
""" | |
A decorator to be used on a function based view that will check if | |
a model instance belongs to the logged in user | |
Keyword arguments: | |
model=None - Name of the model to check. Can be a model |