diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py
index 4169da2..b3cd6f9 100644
a
|
b
|
from django.contrib.auth.management import get_default_username
|
11 | 11 | from django.core import exceptions |
12 | 12 | from django.core.management.base import BaseCommand, CommandError |
13 | 13 | from django.db import DEFAULT_DB_ALIAS |
14 | | from django.utils.encoding import force_str |
| 14 | from django.utils.encoding import force_str, force_text |
15 | 15 | from django.utils.six.moves import input |
16 | 16 | from django.utils.text import capfirst |
17 | 17 | |
… |
… |
class Command(BaseCommand):
|
80 | 80 | try: |
81 | 81 | |
82 | 82 | # Get a username |
| 83 | verbose_field_name = force_text(self.username_field.verbose_name) |
83 | 84 | while username is None: |
84 | 85 | if not username: |
85 | | input_msg = capfirst(self.username_field.verbose_name) |
| 86 | input_msg = capfirst(verbose_field_name) |
86 | 87 | if default_username: |
87 | 88 | input_msg = "%s (leave blank to use '%s')" % ( |
88 | 89 | input_msg, default_username) |
… |
… |
class Command(BaseCommand):
|
102 | 103 | pass |
103 | 104 | else: |
104 | 105 | self.stderr.write("Error: That %s is already taken." % |
105 | | self.username_field.verbose_name) |
| 106 | verbose_field_name) |
106 | 107 | username = None |
107 | 108 | |
108 | 109 | for field_name in self.UserModel.REQUIRED_FIELDS: |
109 | 110 | field = self.UserModel._meta.get_field(field_name) |
110 | 111 | user_data[field_name] = options.get(field_name) |
111 | 112 | while user_data[field_name] is None: |
112 | | raw_value = input(force_str('%s: ' % capfirst(field.verbose_name))) |
| 113 | raw_value = input(force_str('%s: ' % capfirst(force_text(field.verbose_name)))) |
113 | 114 | try: |
114 | 115 | user_data[field_name] = field.clean(raw_value, None) |
115 | 116 | except exceptions.ValidationError as e: |
diff --git a/django/contrib/auth/tests/basic.py b/django/contrib/auth/tests/basic.py
index 8627329..6e2b06a 100644
a
|
b
|
def mock_inputs(inputs):
|
29 | 29 | def mock_input(prompt): |
30 | 30 | # prompt should be encoded in Python 2. This line will raise an |
31 | 31 | # Exception if prompt contains unencoded non-ascii on Python 2. |
| 32 | assert str('__proxy__') not in prompt |
32 | 33 | prompt = str(prompt) |
33 | 34 | if str('leave blank to use') in prompt: |
34 | 35 | return inputs['username'] |
… |
… |
class BasicTestCase(TestCase):
|
180 | 181 | |
181 | 182 | @mock_inputs({'password': "nopasswd", 'username': 'foo'}) |
182 | 183 | def test_createsuperuser_non_ascii_verbose_name(self): |
| 184 | # Aliased so the string doesn't get extracted |
| 185 | from django.utils.translation import ugettext_lazy as ulazy |
183 | 186 | username_field = User._meta.get_field('username') |
184 | 187 | old_verbose_name = username_field.verbose_name |
185 | | username_field.verbose_name = 'uživatel' |
| 188 | username_field.verbose_name = ulazy('uživatel') |
186 | 189 | new_io = StringIO() |
187 | 190 | try: |
188 | 191 | call_command("createsuperuser", |