Add error check to createdefaultadmin command

This commit is contained in:
Jan Tuomi
2017-03-06 02:13:32 +02:00
parent 1c40fab8ae
commit e628b37e0d
@@ -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