Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19725 closed Bug (fixed)

`createsuperuser` command fails with custom User model

Reported by: michisu Owned by: nobody
Component: contrib.auth Version: 1.5-beta-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

If using a custom User model with non-ascii field label, then createsuperuser command fails.

class MyUser(AbstractBaseUser):

    email = models.EmailField(
        u'メールアドレス', max_length=255, unique=True, db_index=True)
    # ...
$ python manage.py createsuperuser
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

Change History (6)

comment:1 Changed 2 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please run the command with the --traceback option so as we can see where's the issue.

comment:2 Changed 2 years ago by michisu

I ran the command with the --traceback option:

$ python manage.py createsuperuser --traceback
Traceback (most recent call last):
  File "/Users/michisu/VirtualEnvs/ppf/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/michisu/VirtualEnvs/ppf/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/Users/michisu/VirtualEnvs/ppf/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 87, in handle
    raw_value = input(input_msg + ': ')
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6: ordinal not in range(128)

comment:3 Changed 2 years ago by claudep

  • Easy pickings set
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 2 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 55c585f1c7a9c91308193f0648caf36203174564:

Fixed #19725 -- Made createsuperuser handle non-ascii prompts

Thanks Michisu for the report.

comment:5 Changed 2 years ago by Claude Paroz <claude@…>

In f5232597ea31bf274b02983f32ba89be4f7bf02b:

[1.5.x] Fixed #19725 -- Made createsuperuser handle non-ascii prompts

Thanks Michisu for the report.
Backport of 55c585f1c from master.

comment:6 Changed 2 years ago by Claude Paroz <claude@…>

In f5232597ea31bf274b02983f32ba89be4f7bf02b:

[1.5.x] Fixed #19725 -- Made createsuperuser handle non-ascii prompts

Thanks Michisu for the report.
Backport of 55c585f1c from master.

Note: See TracTickets for help on using tickets.
Back to Top