Rather than passing the parameter named as field
, you can use dictionary unpacking to use the value of field
as the name of the parameter:
request = update_by_email(email, **{field: field_value})
Using a mock of update_by_email
:
def update_by_email(email=None, **kwargs):
print(kwargs)
When I call
update_field("joe@me.com", "name", "joe")
I see that kwargs
inside update_by_email
is
{'name': 'joe'}