| 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('--password', dest='password', default=None, |
| 10 | help='Specifies the password for the superuser.'), |
| 11 | make_option('--email', dest='email', default=None, |
| 12 | help='Specifies the email address for the superuser.'), |
| 13 | ) |
| 14 | help = 'Used to create a superuser.' |
| 15 | |
| 16 | def handle(self, *args, **options): |
| 17 | username = options.get('username', None) |
| 18 | password = options.get('password', None) |
| 19 | email = options.get('email', None) |
| 20 | |
| 21 | createsuperuser(username=username, password=password, email=email) |
| 22 | |