'Regression test for https://github.com/encode/django-rest-framework/issues/4661'

def test_prefetch_related_excluding_instance_from_original_queryset(self):

    view = UserUpdate.as_view()
    pk = self.user.pk
    groups_pk = self.groups[0].pk
    request = factory.put('/', {'username': 'exclude', 'groups': [groups_pk]}, format='json')
    response = view(request, pk=pk)
    assert (User.objects.get(pk=pk).groups.count() == 1)
    expected = {'id': pk, 'username': 'exclude', 'groups': [1], 'email': 'tom@example.com'}
    assert (response.data == expected)
