Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The @login_required decorator of Django redirects people to /accounts/login when they aren't registered. How to change this URL?

I want it to redirect to "/login" instead of "/accounts/login"

Is there a setting I can change?

like image 689
TIMEX Avatar asked Jan 10 '11 05:01

TIMEX


2 Answers

Add LOGIN_URL = '/login' to your settings.py

See the docs for more.

like image 65
Jake Avatar answered Nov 16 '22 06:11

Jake


You can also do the following:

@login_required(login_url='/login/')

See the docs: https://docs.djangoproject.com/en/dev/topics/auth/default/

like image 45
khalid13 Avatar answered Nov 16 '22 07:11

khalid13