Redirects in Django

52 views Asked by At

I'm working on the Helpdesk module from Django.

I want people who try to access 192.168.x.xxx:8000/helpdesk/ are redirected to the login page: 192.168.x.xxx:8000/helpdesk/login/?next=/helpdesk/

I also want people who try to access an nonexistant page to be redirected to:

  • the homepage if connected, or
  • the login page if not connected.
1

There are 1 answers

0
W. Delahaye On BEST ANSWER

I find an answer for the first part of my question. I just used the import login_required. Just before the function homepage in /helpdesk/public.py and the function index in /helpdesk/kb.py, I put @login_required(login_url='/helpdesk/login/?next=/helpdesk/) and it worked !

Now I try to find the answer of the second part (redirection).