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
Post a Comment