2016-02-24 00:42:45 +01:00
|
|
|
from django.core.management.base import BaseCommand
|
2015-01-16 14:18:34 +01:00
|
|
|
|
2015-09-16 00:55:27 +02:00
|
|
|
from ...models import User
|
2015-01-16 14:18:34 +01:00
|
|
|
|
|
|
|
|
2016-02-24 00:42:45 +01:00
|
|
|
class Command(BaseCommand):
|
2015-01-16 14:18:34 +01:00
|
|
|
"""
|
2015-02-12 20:57:05 +01:00
|
|
|
Command to create or reset the admin user.
|
2015-01-16 14:18:34 +01:00
|
|
|
"""
|
2019-01-06 16:22:33 +01:00
|
|
|
|
|
|
|
help = "Creates or resets the admin user."
|
2016-02-24 00:42:45 +01:00
|
|
|
|
|
|
|
def handle(self, *args, **options):
|
2020-10-19 15:29:55 +02:00
|
|
|
created = User.objects.create_or_reset_admin_user()
|
2015-02-12 20:57:05 +01:00
|
|
|
if created:
|
2020-10-19 15:29:55 +02:00
|
|
|
self.stdout.write(self.style.SUCCESS("Admin user successfully created."))
|
2015-01-16 14:18:34 +01:00
|
|
|
else:
|
2020-10-19 15:29:55 +02:00
|
|
|
self.stdout.write(self.style.SUCCESS("Admin user successfully reset."))
|