Daria Plotnikova
Daria Plotnikova

Reputation: 94

Cancel permissions at some part of function (Django)

Is there any possibility to cancel permissions for some part of function, which specified to function with @is_stuff decorator in Django (1.4.11) with python 2.7?

I mean the following:

@is_stuff(required_perms='<permissions>')
def my_function(request):
    if request.POST['key']:
        # do something as admin (1)
    else:
        # there I want to cancel permissions limitation (2)

I know that this is unusual using of decorators. And that decorators called before performing of function. But I am still interested is it possible? Maybe I can make something like this - dynamically change user.is_staff to True as in second link?

Related links where I didn't find answers: Official docs, official docs (2nd link)

Upvotes: 0

Views: 31

Answers (0)

Related Questions