django - How to run get_or_create() method with dictionary {'field_name': field_value, ...}? -


i need kind of universal solution, (btw. eval(), exec() , ideas not permitted). so..

i have dictionary of fields: dict = {'field_name_1': field_value_1, 'field_name_2': field_name_2, ...} , run: class.objects.get_or_create(dict).

is possible? how correctly?

assuming field_name_1, field_name_2, etc. model's attribute names:

model.objects.get_or_create(**dict) 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -