Skip to content
Snippets Groups Projects
Commit a088c6ba authored by Pierre-antoine Comby's avatar Pierre-antoine Comby
Browse files

add command to enable active/staff

parent e2c1d70e
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
class Command(BaseCommand):
def add_arguments(self,parser):
parser.add_argument('username',nargs='+',type=str)
parser.add_argument('-S',"--SUPER",action='store_true',help='make superuser')
def handle(self,*args,**kwargs):
for uname in kwargs["username"]:
user = User.objects.get(username=uname)
user.is_active = True
if kwargs['SUPER']:
user.is_staff = True
user.save()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment