Permet de créer des superusers
This commit is contained in:
parent
932a20fd17
commit
9c5f3b3a04
1 changed files with 8 additions and 1 deletions
|
@ -14,6 +14,9 @@ class Command(BaseCommand):
|
||||||
parser.add_argument("base_username", type=str, help="Username")
|
parser.add_argument("base_username", type=str, help="Username")
|
||||||
parser.add_argument("password", type=str, help="Password")
|
parser.add_argument("password", type=str, help="Password")
|
||||||
parser.add_argument("full_name", nargs="?", type=str, help="Full name")
|
parser.add_argument("full_name", nargs="?", type=str, help="Full name")
|
||||||
|
parser.add_argument(
|
||||||
|
"--superuser", action="store_true", help="Create a superuser account"
|
||||||
|
)
|
||||||
|
|
||||||
def handle(self, *args, **kwargs):
|
def handle(self, *args, **kwargs):
|
||||||
base_username = kwargs["base_username"]
|
base_username = kwargs["base_username"]
|
||||||
|
@ -27,7 +30,11 @@ class Command(BaseCommand):
|
||||||
user.is_staff = True
|
user.is_staff = True
|
||||||
user.password = make_password(password)
|
user.password = make_password(password)
|
||||||
|
|
||||||
user.full_name = kwargs["full_name"] or ""
|
if kwargs["full_name"]:
|
||||||
|
user.full_name = kwargs["full_name"]
|
||||||
|
|
||||||
|
if kwargs["superuser"]:
|
||||||
|
user.is_superuser = True
|
||||||
|
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue