循环遍历Django项目中的每个模型

时间:2018-01-04 21:51:59

标签: python django django-models

在django中,有没有办法遍历当前数据库中的每个模型?

我希望能够拥有一个函数来获取每个模型的所有模型中的总行数,而不必在每次添加新模型时都使用该函数。

输出类似于

model1行:23

model2行:234

然后如果我要添加新模型,它会自动输出

model1行:23

model2行:234

model3行:0

理想的格式就像是。

C:\Users\Jozef Bar??k\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.4.0.aar\d68bb9d2059935a7891196f4dfb81686\res\drawable-hdpi-v4\abc_ic_menu_share_mtrl_alpha.png: error: file not found.

Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED

1 个答案:

答案 0 :(得分:3)

使用remote: Permission to <new account>/<new account>.github.io.git denied to <old username>. get_models()

count()
相关问题