1👍
✅
Inside your login view, just do this:
def login(request):
"""
Check for login and store the result in login_successful
"""
path = request.GET.get("next")
if login_successful:
if path:
return HttpResponseRedirect(path)
else:
return HttpResponseRedirect(your_earlier_path)
Source:stackexchange.com