How to specify the login_required redirect url in django?

LOGIN_URL in your settings

Reference:

  • LOGIN_URL
  • LOGIN_REDIRECT_URL

you can do this in your view works fine for me without declaring in settings.py

from django.contrib.auth.decorators import login_required

@login_required(login_url='/example url you want redirect/') #redirect when user is not logged in
def myview(request):
    do something
    return something #returns when user is logged in

default login url is: '/accounts/login/'
if you want to change it then go to settings.py

LOGIN_URL='/path/to/url'
LOGIN_REDIRECT_URL='/path/to/redirecturl'