django1.11.1 models 数据库同步方法


Posted in Python onMay 30, 2018

在django1.9之前,数据库同步只需要一条命令:python manage.py syncdb

在djang1.9以后,数据库同步执行指令如下:

同步数据库接口(注意需要切换至python project工作空间所在路径)

python manage.py makemigrations

同步数据

python manage.py migrations

最后登入http://localhost:8080/admin 发现,已经创建数据库表。

windows10 cmd窗口指令

D:\user_workspace>python manage.py makemigrations
Migrations for 'blog':
 blog\migrations\0001_initial.py
 - Create model BlogPost
D:\user_workspace>python manage.py migrate
Operations to perform:
 Apply all migrations: admin, auth, blog, contenttypes, sessions
Running migrations:
 Applying contenttypes.0001_initial... OK
 Applying auth.0001_initial... OK
 Applying admin.0001_initial... OK
 Applying admin.0002_logentry_remove_auto_add... OK
 Applying contenttypes.0002_remove_content_type_name... OK
 Applying auth.0002_alter_permission_name_max_length... OK
 Applying auth.0003_alter_user_email_max_length... OK
 Applying auth.0004_alter_user_username_opts... OK
 Applying auth.0005_alter_user_last_login_null... OK
 Applying auth.0006_require_contenttypes_0002... OK
 Applying auth.0007_alter_validators_add_error_messages... OK
 Applying auth.0008_alter_user_username_max_length... OK
 Applying blog.0001_initial... OK
 Applying sessions.0001_initial... OK

以上这篇django1.11.1 models 数据库同步方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
详解Python的单元测试
Apr 28 Python
详解python单例模式与metaclass
Jan 15 Python
Python中列表元素转为数字的方法分析
Jun 14 Python
浅谈Python实现贪心算法与活动安排问题
Dec 19 Python
详解python使用pip安装第三方库(工具包)速度慢、超时、失败的解决方案
Dec 02 Python
Python lxml解析HTML并用xpath获取元素的方法
Jan 02 Python
python执行精确的小数计算方法
Jan 21 Python
PyQt5组件读取参数的实例
Jun 25 Python
基于Python3.6中的OpenCV实现图片色彩空间的转换
Feb 03 Python
python opencv 图像边框(填充)添加及图像混合的实现方法(末尾实现类似幻灯片渐变的效果)
Mar 09 Python
Python爬虫实现百度翻译功能过程详解
May 29 Python
基于opencv的selenium滑动验证码的实现
Jul 24 Python
Python使用tkinter库实现文本显示用户输入功能示例
May 30 #Python
python自动化报告的输出用例详解
May 30 #Python
Django项目中model的数据处理以及页面交互方法
May 30 #Python
Python实现的生产者、消费者问题完整实例
May 30 #Python
Django 忘记管理员或忘记管理员密码 重设登录密码的方法
May 30 #Python
解决Django数据库makemigrations有变化但是migrate时未变动问题
May 30 #Python
Python实现的本地文件搜索功能示例【测试可用】
May 30 #Python
You might like
php cli 小技巧
2013/06/03 PHP
PHP中的类型约束介绍
2015/05/11 PHP
php常用数组函数实例小结
2016/12/29 PHP
关于jQuery的inArray 方法介绍
2011/10/08 Javascript
浅析offsetLeft,Left,clientLeft之间的区别
2013/11/30 Javascript
JS实现仿Windows经典风格的选项卡Tab切换代码
2015/10/20 Javascript
JS实现鼠标框选效果完整实例
2016/06/20 Javascript
ES6新特性六:promise对象实例详解
2017/04/21 Javascript
react路由配置方式详解
2017/08/07 Javascript
JS中精巧的自动柯里化实现方法
2017/12/12 Javascript
JavaScript ES6 Class类实现原理详解
2020/05/08 Javascript
Python version 2.7 required, which was not found in the registry
2014/08/26 Python
跟老齐学Python之大话题小函数(1)
2014/10/10 Python
Python中使用第三方库xlutils来追加写入Excel文件示例
2015/04/05 Python
全面了解python中的类,对象,方法,属性
2016/09/11 Python
详解Python各大聊天系统的屏蔽脏话功能原理
2016/12/01 Python
浅谈Django REST Framework限速
2017/12/12 Python
django 发送手机验证码的示例代码
2018/04/25 Python
python 实现图片旋转 上下左右 180度旋转的示例
2019/01/24 Python
python 处理telnet返回的More,以及get想要的那个参数方法
2019/02/14 Python
python 怎样将dataframe中的字符串日期转化为日期的方法
2019/09/26 Python
Python编译为二进制so可执行文件实例
2019/12/23 Python
pycharm 激活码及使用方式的详细教程
2020/05/12 Python
基于Python的自媒体小助手---登录页面的实现代码
2020/06/29 Python
阿里巴巴国际站:Alibaba.com
2016/07/21 全球购物
阿迪达斯德国官方网站:adidas德国
2017/07/12 全球购物
美国肌肉和力量商店:Muscle & Strength
2019/06/22 全球购物
小米乌克兰网上商店:Xiaomi.UA
2019/10/29 全球购物
如何客观的进行自我评价
2013/12/17 职场文书
文明市民先进事迹
2014/05/15 职场文书
群众路线教育实践活动心得体会(教师)
2014/10/31 职场文书
2015年财务试用期工作总结
2014/12/24 职场文书
复兴之路纪录片观后感
2015/06/02 职场文书
创业计划书之家教中心
2019/09/25 职场文书
Python爬取英雄联盟MSI直播间弹幕并生成词云图
2021/06/01 Python
Mysql案例刨析事务隔离级别
2021/09/25 MySQL