[Fixed]-Django Update Model Field with Variable User Input… .update(key=value)

1👍

You don’t need to loop through the dict. You can pass it as a kwarg expansion.

def update_profile(message):
    list_of_updates = message['profile_updates']
    user_update_id = message['user_id']

    for update in list_of_updates['custom_permissions']:
        User.objects.filter(id=user_update_id).update(**update)

Leave a comment