Is there a way to programmatically update Models using key, value pairs in peewee? I have been trying to do it by iterating through **kwargs, using the following code:
for key, value in kwargs.items():
if value is not None:
self.physician.update(key=value)
But this gives me the following error:
AttributeError: type object 'RequestDetail' has no attribute 'key'
Is there any way to get the update() method to accept the key argument as the value of 'key' instead of interpreting it literally?
Can you try:
self.physician.update({key:value}).execute()
Putting it in a dict might just do the trick, you can also do
self.physician.update(kwargs).execute()
Since kwargs is also a dict but ofcourse you still need to remove the values that are None first