0

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...?

Community
  • 1
  • 1
alias51
  • 8,178
  • 22
  • 94
  • 166

5 Answers5

4

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

python manage.py createsuperuser --username thisismyusername
knbk
  • 52,111
  • 9
  • 124
  • 122
  • 1
    @alias51 What's the complete command you're running? Do you happen to have a custom user model? – knbk Jan 17 '15 at 18:29
  • it's `python manage.py createsuperuser` then I follow the prompts to enter email and password and get the above error. Yes I have a custom user model. – alias51 Jan 17 '15 at 18:47
  • @alias51 Can you post your model? – knbk Jan 17 '15 at 20:42
2

I faced the same problem, after migrating the changes I was able to create the super user.

Try this:

python manage.py makemigrations

python manage.py migrate

python manage.py createsuperuser
Graham
  • 7,431
  • 18
  • 59
  • 84
0

Just Because you have not applied migrations after creating your model. So run

python manage.py makemigrations and then python manage.py migrate

Now migrations have been applied and you can create superuser by running

python manage.py createsuperuser

Ramandeep Singh
  • 552
  • 6
  • 11
0

Using SQL Lite I removed the DB file and run the commands:

python manage.py migrate
python manage.py makemigrations
Lorenzo Lerate
  • 3,552
  • 3
  • 26
  • 25
-2
$ run python manage.py syncdb

The system would try to sync and would ask:

You have installed Django's auth system, and don't have any superusers                  defined.
Would you like to create one now? (yes/no): yes
Username (leave blank to use 'yogesh'): 
Email address: yogesh.gupta38@gmail.com
Password: 
Password (again): 
Superuser created successfully.

I was facing the same problem and this stuff worked in my case.

yogi
  • 31
  • 1
  • 6