在 Django 中创建超级用户时出错
Error creating superuser in Django
我正在尝试创建一个超级用户来访问我的应用程序中的 Django 管理框架。我在 Windows 8.1 机器上使用 Vagrant:
> ./manage.py createsuperuser
但是,我收到以下错误:
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
我在别处 (here) and (here) 读到这是一个 "locale" 问题,但据我所知这是一个 OSX 错误,而且我在 vagrant 虚拟机上。 ..?
使用 --username
标志而不是直接传递用户名:
python manage.py createsuperuser --username thisismyusername
$ run python manage.py syncdb
系统会尝试同步并询问:
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.
我遇到了同样的问题,这些东西对我有用。
我遇到了同样的问题,在迁移更改后我能够创建超级用户。
试试这个:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
只是因为您在创建模型后没有应用迁移。
所以 运行
python manage.py makemigrations
然后
python manage.py migrate
现在已应用迁移,您可以通过 运行ning
创建超级用户
python manage.py createsuperuser
使用 SQL Lite 我删除了数据库文件和 运行 命令:
python manage.py migrate
python manage.py makemigrations
我正在尝试创建一个超级用户来访问我的应用程序中的 Django 管理框架。我在 Windows 8.1 机器上使用 Vagrant:
> ./manage.py createsuperuser
但是,我收到以下错误:
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
我在别处 (here) and (here) 读到这是一个 "locale" 问题,但据我所知这是一个 OSX 错误,而且我在 vagrant 虚拟机上。 ..?
使用 --username
标志而不是直接传递用户名:
python manage.py createsuperuser --username thisismyusername
$ run python manage.py syncdb
系统会尝试同步并询问:
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.
我遇到了同样的问题,这些东西对我有用。
我遇到了同样的问题,在迁移更改后我能够创建超级用户。
试试这个:
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
只是因为您在创建模型后没有应用迁移。 所以 运行
python manage.py makemigrations
然后
python manage.py migrate
现在已应用迁移,您可以通过 运行ning
创建超级用户python manage.py createsuperuser
使用 SQL Lite 我删除了数据库文件和 运行 命令:
python manage.py migrate
python manage.py makemigrations