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:


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 loaddata mymodel manually after syncdb

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



粤ICP备14056181号  © 2014-2021