[Answered ]-Django login to previous page

2👍

By default, the redirection is driven by ?next= in the URL, provided you have the correct request context preprocessors in the settings.

settings.py:

TEMPLATE_CONTEXT_PROCESSORS += (
    "django.core.context_processors.request",
)

And in the template, where you would be sending the user from,:

base.html:

<a href="{% url 'login' %}?next={{request.path}}">Log me in here</a>

Leave a comment