alias51 alias51 - 3 years ago 223
Python Question

Error creating superuser in Django

I am trying to create a superuser to access the Django admin framework in my app. I am using Vagrant on a Windows 8.1 machine:

> ./manage.py createsuperuser


However, I get the following error:

Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, i
n execute_from_command_line
utility.execute()
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, i
n execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in ru
n_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in ex
ecute
output = self.handle(*args, **options)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsu
peruser.py", line 141, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/vagrant/myapp/accounts/managers.py", line 52, in create_superuser
return self._create_user(email, password, True, True, **extra_fields)
File "/vagrant/myapp/accounts/managers.py", line 31, in _create_user
user.set_slug()
File "/vagrant/myapp/accounts/models.py", line 164, in set_slug
slug = slugify(self.username, max_length=50).lower()
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/slugify/main.py", line 101, in slugify
text = join_words(words, separator, max_length)
File "/home/vagrant/Envs/myapp/local/lib/python2.7/site-packages/slugify/main.py", line 78, in join_words
text = next(words) # text = words.pop(0)
StopIteration


I've read elsewhere (here) and (here) that this is a "locale" issue, but my understanding this is a OSX bug and I'm on a vagrant virtual machine...?

Answer Source

Use the --username flag instead of directly passing a username:

python manage.py createsuperuser --username thisismyusername
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download