简体   繁体   English

Django夹具作为python脚本

[英]Django fixtures as a python script

Writing .json or .yaml for a lot of fixtures is tiresome (especially for Users password for example), just doing it in python with a nice for loop is really nice and fast. 为许多装置编写.json或.yaml很麻烦(特别是对于用户密码),仅在python中使用一个不错的for循环来完成它确实非常好且快速。

But I can't find other people doing it like that. 但是我找不到其他人那样做。

  • Is this a bad practice ? 这是不好的做法吗?
  • What's your way to do it ? 你怎么做呢? .py in the fixtures/ directory, in a separate script/ directory or as a management command ? .fixes /目录中的.py,在单独的script /目录中还是作为管理命令?

Django具有用于从数据库准备夹具的内部命令: https : //docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata-app-label-app-label-app-label-model

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM