Add make-admin command to uncloud_auth
This commit is contained in:
parent
268e08c4db
commit
718abab9d2
3 changed files with 23 additions and 3 deletions
16
uncloud_auth/management/commands/make-admin.py
Normal file
16
uncloud_auth/management/commands/make-admin.py
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth import get_user_model
|
||||
import sys
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Give Admin rights to existing user'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('username', type=str)
|
||||
|
||||
def handle(self, *args, **options):
|
||||
user = get_user_model().objects.get(username=options['username'])
|
||||
user.is_staff = True
|
||||
user.save()
|
||||
|
||||
print("{} is now admin.".format(user.username))
|
||||
Loading…
Add table
Add a link
Reference in a new issue