Skip to content Skip to sidebar Skip to footer

Redirect Back After Login Django-registration-redux

I am using django-registration-redux and i have a login form in my navbar. I would like to stay on the same page after login. ie. if i am at mypage.com/polls/example after login i

Solution 1:

You could use next :

<form class="navbar-form" method="POST" action="{{ login_url }}?next={{request.path}}">

This will add a GET request to your form that points back to the current page.

For request.path to work you have to define template context processors in your settings.py

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.core.context_processors.auth",
    "django.core.context_processors.debug",
    "django.core.context_processors.i18n",
    "django.core.context_processors.media",
    "django.core.context_processors.request",
)

Post a Comment for "Redirect Back After Login Django-registration-redux"