在创建表时执行Django fixture
Is there a way to execute a Django fixture just once - when the appropriate table is created? I have some initial data that should be put in the app tables, but once the tables are there, I don't want every ./manage.py syncdb
to refresh the data. According to Django docs it seems this can only be done for fixtures in SQL format and not JSON / YAML:
是否有一种方法可以只在创建合适的表时执行Django fixture ?我有一些最初的数据应该放在应用程序表中,但是一旦表出现了,我不想要每一个。/管理。py syncdb刷新数据。根据Django文档,这似乎只能用SQL格式来完成,而不是JSON / YAML:
http://docs.djangoproject.com/en/1.3/howto/initial-data/
http://docs.djangoproject.com/en/1.3/howto/initial-data/
1 个解决方案
#1
1
You're going to want to use the post_syncdb signal, and filter/manually load the fixture via the underlying methods when specific apps or models are created.
您将希望使用post_syncdb信号,并在创建特定应用程序或模型时通过底层方法过滤/手动加载fixture。
更多相关文章
- 检查 NaN 数据值 (C/C++/Python 实现)
- 在两台服务器上有效地在两个Django应用程序之间进行通信(多租户)
- 【python网络爬虫三】爬取动态数据及数据入库
- 如何停止Py_Initialise应用程序的崩溃?
- 数据挖掘(三)分类模型的描述与性能评估,以决策树为例
- 用于Python项目的低内存和最快查询数据库
- python爬虫:爬取豌豆荚APP第一页数据信息(selenium)
- Pandas 文本数据方法 findall( )
- TensorFlow数据集(一)——数据集的基本使用方法