Add error check to createdefaultadmin command
This commit is contained in:
@@ -7,6 +7,10 @@ class Command(BaseCommand):
|
||||
password = "password123"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
if User.objects.filter(username=self.user_name).exists():
|
||||
self.stdout.write("Default admin already exists. Skipping.")
|
||||
return
|
||||
|
||||
u = User(username=self.user_name)
|
||||
u.set_password(self.password)
|
||||
u.is_superuser = True
|
||||
|
||||
Reference in New Issue
Block a user