N
N
NyxDeveloper2021-02-01 10:45:32
Django
NyxDeveloper, 2021-02-01 10:45:32

How to pass a function parameter to a decorator?

I am checking users for belonging to certain groups, I want to implement this through a decorator. I thought to see how other similar decorators like login_required() work, but it's not clear where it gets information about the user from. Tell me how can I implement such functionality and can it be done in this way?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-02-01
@NyxDeveloper

Well, you have to keep poking into the docks or sources, everything is done there based on user_passes_test, for which you write your function with the user parameter

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question