diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py
index 558ee64..ae2f213 100644
a
|
b
|
from django.contrib.auth.password_validation import validate_password
|
12 | 12 | from django.core import exceptions |
13 | 13 | from django.core.management.base import BaseCommand, CommandError |
14 | 14 | from django.db import DEFAULT_DB_ALIAS |
| 15 | from django.db.utils import OperationalError |
15 | 16 | from django.utils.encoding import force_str |
16 | 17 | from django.utils.six.moves import input |
17 | 18 | from django.utils.text import capfirst |
… |
… |
class Command(BaseCommand):
|
82 | 83 | # Prompt for username/password, and any other required fields. |
83 | 84 | # Enclose this whole thing in a try/except to catch |
84 | 85 | # KeyboardInterrupt and exit gracefully. |
85 | | default_username = get_default_username() |
| 86 | try: |
| 87 | default_username = get_default_username() |
| 88 | except OperationalError: |
| 89 | raise CommandError("You must execute `manage.py migrate` once before creating a super user") |
86 | 90 | try: |
87 | 91 | |
88 | 92 | if hasattr(self.stdin, 'isatty') and not self.stdin.isatty(): |