login page redirect to main index page

前端 未结 3 1184
余生分开走
余生分开走 2021-01-26 12:47

im new to django. actually i want on correct login user it redirect to my index page. here is my login handler.

def login(request):
    template = \"../templates         


        
相关标签:
3条回答
  • 2021-01-26 13:03

    if you will use a default login handler - there is a default setting LOGIN_REDIRECT_URL.

    0 讨论(0)
  • 2021-01-26 13:09

    You need to setup Django decorators and setup the settings for it to work. Here is a link for Django Decorators https://docs.djangoproject.com/en/dev/topics/http/decorators/

    Add these to your settings.py:

    LOGIN_URL = '/login/' LOGIN_REDIRECT_URL = '/homepage/'

    Just change the values according to your specifications. (/login/ and /homepage/ are URLs).

    0 讨论(0)
  • 2021-01-26 13:13

    You need to return a HttpResponseRedirect

    0 讨论(0)
提交回复
热议问题