Reputation: 13
That way or you can do this:
for key, value in data.items():
instance = model_class.objects(key = value)
or can only be done this way?:
instance = model_class.objects(pk = value)
Upvotes: 1
Views: 88
Reputation: 474161
Deliver keyword arguments by unpacking the dictionary:
instance = model_class.objects.filter(**data)
where keys in data
dictionary are model_class
field names.
Upvotes: 2