From 23fd5f47a8bbbe7be9acebe31fa1340730f666fb Mon Sep 17 00:00:00 2001 From: Daniel Gray Date: Wed, 3 Jul 2024 14:53:14 +0200 Subject: [PATCH] cleanuped code --- app/accounts/views.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/accounts/views.py b/app/accounts/views.py index dc39f6f3..b2eabcb4 100644 --- a/app/accounts/views.py +++ b/app/accounts/views.py @@ -8,12 +8,10 @@ def register(request): if request.method == "POST": form = CustomUserCreationForm(request.POST) if form.is_valid(): - user = form.save( - commit=False - ) # Save the user object without committing to the database - user.is_staff = True # Set the user as a staff member - user.save() # Save the user object to the database - login(request, user) # Log the user in + user = form.save(commit=False) + user.is_staff = True + user.save() + login(request, user) return redirect("home") else: form = CustomUserCreationForm()