| 1 | from django.core.management.base import BaseCommand |
| 2 | from optparse import make_option |
| 3 | from django.contrib.auth.create_superuser import createsuperuser |
| 4 | |
| 5 | class Command(BaseCommand): |
| 6 | option_list = BaseCommand.option_list + ( |
| 7 | make_option('--username', dest='username', default=None, |
| 8 | help='Specifies the username for the superuser.'), |
| 9 | make_option('--email', dest='email', default=None, |
| 10 | help='Specifies the email address for the superuser.'), |
| 11 | ) |
| 12 | help = 'Used to create a superuser.' |
| 13 | |
| 14 | def handle(self, *args, **options): |
| 15 | username = options.get('username', None) |
| 16 | email = options.get('email', None) |
| 17 | |
| 18 | createsuperuser(username=username, password=None, email=email) |