Django中migrate和syncdb命令之间的区别?

2024-10-03 23:30:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我没能找到这个django.org网站,那么django1.7是否应该在第一次运行时自动创建超级用户?在

最后运行的是Django命令。现在命令是migrate,它似乎不会提示您创建超级用户。在

我可以通过运行python轻松地解决这个问题管理.pycreatesuperuser,但是这是一个bug还是像所有教程在第一次运行时建议您创建user一样工作?在

这就是我运行migrate时所做的。在

Operations to perform:
  Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK

这是一个新的virtualenv,它使用了python2.7、pip和django1.7


Tags: django用户org命令网站migrations教程ok
2条回答

基本上遵循与South相同的过程(至少对于标准迁移过程而言),它只是稍微简化了一些事情。在

enter image description here

迁移命令之后,运行python manage.py createsuperuser命令来创建超级用户。在

另请阅读https://realpython.com/blog/python/django-migrations-a-primer/

从文档- 迁移:

Unlike syncdb, this command does not prompt you to create a superuser if one doesn’t exist (assuming you are using django.contrib.auth). Use createsuperuser to do that if you wish.

https://docs.djangoproject.com/en/1.8/ref/django-admin/#migrate-app-label-migrationname

相关问题 更多 >