diff --git a/archivist/apps/authentication/views.py b/archivist/apps/authentication/views.py index 931d66c..f5ab108 100644 --- a/archivist/apps/authentication/views.py +++ b/archivist/apps/authentication/views.py @@ -11,8 +11,8 @@ from .forms import LoginForm, SignUpForm def login_view(request): if request.user.is_authenticated: # User is already logged in, redirect them to the home page - return redirect('/') - + next_page = request.GET.get('next', '/') + return redirect(next_page) form = LoginForm(request.POST or None) msg = None @@ -25,7 +25,8 @@ def login_view(request): user = authenticate(username=username, password=password) if user is not None: login(request, user) - return redirect("/") + next_page = request.GET.get('next', '/') + return redirect(next_page) else: msg = 'Invalid credentials' else: