如何在Django 1.9.6中创建超级用户帐户 [英] How do I create a superuser account in Django 1.9.6

查看:115
本文介绍了如何在Django 1.9.6中创建超级用户帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读一本关于Django的书籍(Sanjeev Jaiswal和Ratan Kumar的学习Django Web开发),但是该书基于Django的早期版本(1.9版之前)。为了用表填充数据库,本书使用syncdb命令:

I am reading a book ("Learning Django Web Development" by Sanjeev Jaiswal and Ratan Kumar) on Django, but the book is based on an earlier version of Django (prior to version 1.9). In order to populate the database with tables, the book uses the syncdb command:

$ python manage.py syncdb

然后这本书说终端会提示您创建一个超级用户帐户。

Then the book says that terminal will prompt you to create a superuser account.

syncdb命令在Django 1.9及更高版本中不再使用。经过研究后,似乎migrate命令用表填充了数据库,但是它没有提示创建超级用户帐户。如何在Django 1.9.6中执行此操作?

the syncdb command is no longer used in Django version 1.9 and up. After some research, it seems as if the migrate command populates the databse with tables, but it does not prompt the creation of a superuser account. How can I do this in Django 1.9.6?

推荐答案

我认为您想运行以下命令:

I think you want to run these commands:

python manage.py makemigrations 根据您的模型创建迁移文件

python manage.py makemigrations creates migration files based on your models

python manage.py migration 将基于创建的迁移文件在数据库中创建表

python manage.py migrate will create the tables in your db based on the migration files created

(请参见文档了解有关数据库迁移的更多详细信息)

(see docs for more details on database migrations)

python manage.py createsuperuser 将在数据库中为您的应用程序创建一个超级用户(文档

python manage.py createsuperuser will create a superuser for your application in the database (docs)

这篇关于如何在Django 1.9.6中创建超级用户帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆