P
P
pvgdrk2014-05-20 22:36:55
Django
pvgdrk, 2014-05-20 22:36:55

Django. is_authenticated is needed in every function?

Django project. The function that loads the main page on the site checks if the user is logged in: if request.user.is_authenticated(): ... , if not, sends it to the login page.
Other functions accept and return various data from the database, some return markup. Do any of these other functions need to check with is_authenticated, or a decorator, to prevent unlogged users from accessing the database?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Solovyov, 2014-05-20
@pvgdrk

if the data should not be available to unregistered users, then you need to add a decorator, but not for each function, but for the module in which these functions are located or close the entire route for an unlogged user.

Z
zxmd, 2014-05-21
@zxmd

You can use the decorator https://docs.djangoproject.com/en/1.2/topics/auth/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question