django fixtures:在syncdb上加載多個燈具

[英]django fixtures: load multiple fixtures on syncdb


I have a lot of things in my initial_data.json right now. I wondered if there is a way to split the data in files (by model) so that all of the files are loaded via same manage syncdb command?

我的initial_data.json現在有很多東西。我想知道是否有辦法將文件中的數據拆分(按型號),以便所有文件都通過相同的manage syncdb命令加載?

I recently revisited the problem, and came up with a better way of hooking code to 'real' post_syncdb signal:

我最近重新討論了這個問題,並提出了一種更好的方法來將代碼掛鈎到'真正的'post_syncdb信號:

http://www.djangosnippets.org/snippets/1988/

http://www.djangosnippets.org/snippets/1988/

1 个解决方案

#1


1  

Yes, syncdb will load everything from your app/sql/modelname.sql on syncdb once for each model file - that's not exactly json though, only pure SQL can go there.

是的,syncdb將為每個模型文件在syncdb上的app / sql / modelname.sql加載一次 - 這不完全是json,只有純SQL可以去那里。

If you want to split your json fixtures you have to name them something like mymodel.json, put it inside app/fixtures/, and do manage.py loaddata mymodel manually after syncdb

如果你想分割你的json燈具,你必須將它們命名為mymodel.json,將它放在app / fixtures /中,並在syncdb之后手動執行manage.py loaddata mymodel


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/12/15/725e82c7706e867c0bddc6c936034173.html



 
粤ICP备14056181号  © 2014-2021 ITdaan.com