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

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -