[Fixed]-Is there an easy way to update a **kwarg while querying? django

1👍

Try this:

def user_profile(self, **kwargs):
    default_fields = {
        'is_deleted': False,
        'is_staff': False,
        'is_active': False
    }
    default_fields.update(kwargs)

    return Profile.objects.filter(**default_fields)

Basically just turn your default_fields dict into the base dict so if you want to override ‘is_staff’, just pass is_staff via kwargs.

👤munsu

Leave a comment