pmo*_*niq 1 django django-models
我需要某种通用解决方案,(顺便说一句。eval()、exec() 和这样的想法是不允许的)。所以..
我有一些字段字典: dict = {'field_name_1': field_value_1, 'field_name_2': field_name_2, ...} 我想运行:
Class.objects.get_or_create(dict).
是否可以?如何正确地做到这一点?
假设field_name_1,field_name_2等为模型的属性名称:
Model.objects.get_or_create(**dict)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
603 次 |
| 最近记录: |