django1.11.1 models 数据库同步方法
在django1.9之前,数据库同步只需要一条命令:pythonmanage.pysyncdb
在djang1.9以后,数据库同步执行指令如下:
同步数据库接口(注意需要切换至pythonproject工作空间所在路径)
pythonmanage.pymakemigrations
同步数据
pythonmanage.pymigrations
最后登入http://localhost:8080/admin发现,已经创建数据库表。
windows10cmd窗口指令
D:\user_workspace>pythonmanage.pymakemigrations Migrationsfor'blog': blog\migrations\0001_initial.py -CreatemodelBlogPost
D:\user_workspace>pythonmanage.pymigrate Operationstoperform: Applyallmigrations:admin,auth,blog,contenttypes,sessions Runningmigrations: Applyingcontenttypes.0001_initial...OK Applyingauth.0001_initial...OK Applyingadmin.0001_initial...OK Applyingadmin.0002_logentry_remove_auto_add...OK Applyingcontenttypes.0002_remove_content_type_name...OK Applyingauth.0002_alter_permission_name_max_length...OK Applyingauth.0003_alter_user_email_max_length...OK Applyingauth.0004_alter_user_username_opts...OK Applyingauth.0005_alter_user_last_login_null...OK Applyingauth.0006_require_contenttypes_0002...OK Applyingauth.0007_alter_validators_add_error_messages...OK Applyingauth.0008_alter_user_username_max_length...OK Applyingblog.0001_initial...OK Applyingsessions.0001_initial...OK
以上这篇django1.11.1models数据库同步方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。