Mock django function

Hi, i want to mock django.contrib.auth.get_user_model that is used inside method get in my view.

I used patch @patch(‘django.contrib.auth.get_user_model’) but with no effect.
I appreciate any helps.

Bellow a sample of code:

def test_activate(self, get_user_model):
user = self._get_user()
get_user_model.return_value = user

The function get_user_model is supposed to get the Model class, not an instance of the model. The appropriate return value from that function might be django.contrib.auth.User - or whatever model you are using as your user class. See Customizing authentication in Django | Django documentation | Django