From 32a6ab35fa6be8706d95564a7c692dc9dfe10e3c Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Tue, 22 Dec 2020 18:51:40 +0100 Subject: [PATCH] setup existing user --- conf/create_superuser.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/conf/create_superuser.py b/conf/create_superuser.py index b35ab77..b6312d8 100644 --- a/conf/create_superuser.py +++ b/conf/create_superuser.py @@ -24,12 +24,15 @@ def main(): from django.contrib.auth import get_user_model User = get_user_model() - super_user = User.objects.filter(username=username).first() - if super_user: - print('Update existing super user and set his password.', file=sys.stderr) - super_user.set_password(password) - super_user.email=email - super_user.save() + user = User.objects.filter(username=username).first() + if user: + print('Update existing user and set his password.', file=sys.stderr) + user.is_active = True + user.is_staff = True + user.is_superuser = True + user.set_password(password) + user.email = email + user.save() else: print('Create new super user', file=sys.stderr) User.objects.create_superuser(