From e11aa0552ba31ced52543b6524593b637be36aa6 Mon Sep 17 00:00:00 2001 From: ZEZE1020 Date: Mon, 13 Jan 2025 11:38:19 +0300 Subject: [PATCH] User on boarding update --- accounts/views.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/accounts/views.py b/accounts/views.py index 54b928a..6f7217b 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -72,15 +72,13 @@ def user_profile(request, user_id): return render(request, 'accounts/profile.html', context) def login_view(request): - if request.method == 'POST': - form = AuthenticationForm(data=request.POST) - if form.is_valid(): - user = form.get_user() - login(request, user) - return redirect('home') - else: - form = AuthenticationForm() - return render(request, 'login.html', {'form': form}) + form = AuthenticationForm(data=request.POST or None) + if request.method == 'POST' and form.is_valid(): + user = form.get_user() + login(request, user) + return redirect('home') + + return render(request, 'login.html', {'form': form}) def logout_view(request):