1

Im trying to access my inner page of my application which has '@login_required () ' enabled so it redirects me to login page., the URL format looks like below

http://127.0.0.1:8000/login/?next=/user/19/

After login is there any configuration which allows me to take it to the actual page that I requested. I have to following code by default. How to redirect to actual page when I got redirected.

if user is not None:
                print "Valid user"
                login(request, user)
                return HttpResponseRedirect('/')
shan
  • 35
  • 3

1 Answers1

0

Use request.GET['next']:

return HttpResponseRedirect(request.GET.get('next', '/'))

Also see: Django: Redirect to previous page after login

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195