惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
U
Unit 42
D
Docker
Hugging Face - Blog
Hugging Face - Blog
博客园 - 聂微东
Recent Announcements
Recent Announcements
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI
V
Visual Studio Blog
I
InfoQ
Google DeepMind News
Google DeepMind News
小众软件
小众软件
L
LangChain Blog
C
Check Point Blog
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
J
Java Code Geeks
罗磊的独立博客

夜行人

回家路上 第一期的直播演示项目 震动检测器 正能量 在线参观CodeLab Neverland 发布 CodeLab Adapter 3.3.1 DynamicTable 之 纸糊方向盘 CodeLab DynamicTable: 一个可实施的技术方案 CodeLab Insight 发布 Alpha 版 情人节 Home Assistant 周报 && IoT 周报 (02) Joplin: 关注隐私的 Evernote 开源替代软件 浏览器的未来与 Web 传感器 Home Assistant 周报 && IoT 周报 (01) 百宝箱(01) 论自由 介绍 WebThings Home Assistant 周报 && iot 周报 (00) 百宝箱(00) 毛姆读书心得 传世之作 周末徒步 CodeLab Adapter ❤️ Jupyter/Python 航班 躲雨 夏令营途中 [译]思想--作为一种技术 The future of coding 美国之行 三门问题的程序模拟
django笔记之fixtures
2014-05-30 · via 夜行人

主要参考官方文档

###为何用它

Providing initial data for models

###Where Django finds fixture files

By default, Django looks in the fixtures directory inside each app for fixtures. You can set the FIXTURE_DIRS setting to a list of additional directories where Django should look.

###相关指令

  • python manage.py loaddata APPNAME
  • python manage.py dumpdata APPNAME

###导出数据 参考这里

  • python manage.py dumpdata APPNAME
  • The output of dumpdata can be used as input for loaddata.
  • Outputs to standard output all data in the database associated with the named application(s).
  • By default dumpdata will output all the serialized data to standard output.

###导入数据 参考这里

  • python manage.py dumpdata APPNAME,会自动加载APPNAME/fixtures/xx.json

###实例演示 需求:对myblog(一个app)的数据进行导出与导入 ####导出

  • python manage.py dumpdata myblog>mydata.json
  • 将mydata.json剪切到myblog/fixtures文件夹下 ####导入
  • python manage.py loaddata myblog

文章作者 种瓜

上次更新 2014-05-30