-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e3370c
commit 69fe5e2
Showing
2 changed files
with
36 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
from django.core.management.base import BaseCommand | ||
from django.core.management import call_command | ||
|
||
|
||
class Command(BaseCommand): | ||
help = ('Usage: Create an API token for the user during the database ' | ||
'reset, and set admin rights.') | ||
|
||
def handle(self, *args, **options): | ||
call_command('shell', | ||
'-c', | ||
( | ||
"from rest_framework.authtoken.models import Token;" | ||
"from api.models import User;" | ||
"user = User.objects.get(id=2);" | ||
"user.is_staff = True;" | ||
"user.is_superuser = True;" | ||
"user.save();" | ||
"token = Token.objects.create(user=user," | ||
"key='1d18b962d6f976b0b7e8fcf9fcc39b56cf278051');" | ||
"print(f'Token for {user.email}: {token.key}')" | ||
)) | ||
call_command( | ||
'shell', | ||
'-c', | ||
( | ||
"from rest_framework.authtoken.models import Token;" | ||
"from api.models import User;" | ||
"user = User.objects.get(id=2);" | ||
"user.is_staff = True;" | ||
"user.is_superuser = True;" | ||
"user.save();" | ||
"token = Token.objects.create(user=user," | ||
"key='1d18b962d6f976b0b7e8fcf9fcc39b56cf278051');" | ||
"print(f'Token for {user.email}: {token.key}')" | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters