Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#19933 closed Bug (fixed)

"ValueError: unknown locale: en_NG" in Django 1.5

Reported by: lanre.hbs@… Owned by: nobody
Component: Internationalization Version: 1.5-rc-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


I get the error

ValueError: unknown locale: en_NG

after I create a new Django 1.5 project, run "python syncdb" and attempt to define a superuser. This was also a bug in Django 1.4 when it was first released but was eventually fixed.

Attachments (1)

19933-1.diff (1.4 KB) - added by Claude Paroz 5 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by Claude Paroz

Please run the command with the --traceback option and provide the full traceback on the ticket.

comment:2 Changed 5 years ago by lanre.hbs@…

Please find the full traceback below based on including the --traceback option:

Traceback (most recent call last):

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 222, in run_from_argv

self.execute(*args, options.dict)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 255, in execute

output = self.handle(*args, options)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 385, in handle

return self.handle_noargs(options)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/commands/", line 109, in handle_noargs

emit_post_sync_signal(created_models, verbosity, interactive, db)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 195, in emit_post_sync_signal

interactive=interactive, db=db)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/dispatch/", line 170, in send

response = receiver(signal=self, sender=sender, named)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/", line 117, in create_superuser

call_command("createsuperuser", interactive=True, database=db)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 161, in call_command

return klass.execute(*args, defaults)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/", line 255, in execute

output = self.handle(*args, options)

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/", line 79, in handle

default_username = get_default_username()

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/", line 161, in get_default_username

default_username = get_system_username()

File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/", line 136, in get_system_username

default_locale = locale.getdefaultlocale()[1]

File "/home/lanre/.virtualenvs/D1.5R/lib/python2.7/", line 511, in getdefaultlocale

return _parse_localename(localename)

File "/home/lanre/.virtualenvs/D1.5R/lib/python2.7/", line 443, in _parse_localename

raise ValueError, 'unknown locale: %s' % localename

ValueError: unknown locale: en_NG

Version 0, edited 5 years ago by lanre.hbs@… (next)

comment:3 Changed 5 years ago by Claude Paroz

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Thanks for the traceback.

Python-related bugs:

Related Django ticket: #16017

We should definitely catch ValueError in get_system_username.

Changed 5 years ago by Claude Paroz

Attachment: 19933-1.diff added


comment:4 Changed 5 years ago by Claude Paroz

Has patch: set

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

In 8e8c9b908a0fe0d2437fcf3f0378eb2a62b81986:

Fixed getting default encoding in get_system_username

Refs #19933.

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

Resolution: fixed
Status: newclosed

In 327c98ff08a95205919df4ae31dc633c1acec643:

[1.5.x] Fixed #19933 -- Catched ValueError in get_system_username

Thanks lanre.hbs at for the report.

comment:7 Changed 5 years ago by Claude Paroz

As you can see by comparing the patches, I chose a different fix for stable (minimal potential impact) and master (bit of refactoring).

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