初始化管理员用户的时候,由判断 root 用户名是否存在改为是否有用户存在

防止 root 用户被改名之后创建重复的 root 用户的问题
This commit is contained in:
李扬 2018-12-09 14:43:42 +08:00 committed by GitHub
parent f94223e5c9
commit a5722d9f2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,7 +20,7 @@ class Command(BaseCommand):
exit(1)
if action == "create_super_admin":
if User.objects.filter(username=username).exists():
if User.objects.filter(id=1).exists():
self.stdout.write(self.style.SUCCESS(f"User {username} exists, operation ignored"))
exit()