Hello! Access to the site is strictly through login and password. The question is if there is url / search, / test1, / test2, etc. so that there is no unauthorized access every time use if request.user.is_authenticated () to check the url?

def search(request): if request.user.is_authenticated(): ....... def tes1(request): if request.user.is_authenticated(): ....... 

etc.

    1 answer 1

    Login_required decorator

    login_required() does the following:

    • If the user isn't logged in, redirect to settings.LOGIN_URL , passing the current path to the query string. Example: /accounts/login/?next=/polls/3/ .
    • If the user is logged in, execute the view normally. The user is logged in.