  class TestPrefetchRelatedUpdates(TestCase):
      def setUp(self):
          self.user = User.objects.create(username='tom', email='tom@example.com')
          self.groups = [Group.objects.create(name='a'), Group.objects.create(name='b')]
          set_many(self.user, 'groups', self.groups)
          self.user.save()
  
      def test_prefetch_related_updates(self):
          view = UserUpdate.as_view()
          pk = self.user.pk
          groups_pk = self.groups[0].pk
 
</s> remove         pk = get_related_model(pk)._meta.pk
        rel = get_remote_field(pk)
 </s> add         pk = pk.remote_field.model._meta.pk
        rel = pk.remote_field </s> remove     rel = get_remote_field(pk)
 </s> add     rel = pk.remote_field </s> remove         set_many(user, 'user_permissions', [
 </s> add         user.user_permissions.set([ </s> remove         self.assertTrue(is_anonymous(self.request.user))
 </s> add         self.assertTrue(self.request.user.is_anonymous) </s> remove         self.assertFalse(is_anonymous(self.request.user))
 </s> add         self.assertFalse(self.request.user.is_anonymous)
        self.user.groups.set(self.groups)
  class TestPrefetchRelatedUpdates(TestCase):
      def setUp(self):
          self.user = User.objects.create(username='tom', email='tom@example.com')
          self.groups = [Group.objects.create(name='a'), Group.objects.create(name='b')]
        self.user.groups.set(self.groups)
        self.user.groups.set(self.groups)
  
      def test_prefetch_related_updates(self):
          view = UserUpdate.as_view()
          pk = self.user.pk
          groups_pk = self.groups[0].pk
keep keep keep keep replace replace keep keep keep keep keep
 Remove Django 1.8 & 1.9 compatibility code (#5481)

* Identify code that needs to be pulled out of/removed from compat.py

* Extract modern code from get_names_and_managers in compat.py and remove compat code

* Extract modern code from is_authenticated() in compat.py and remove.

* Extract modern code from is_anonymous() in compat.py and remove

* Extract modern code from get_related_model() from compat.py and remove

* Extract modern code from value_from_object() in compat.py and remove

* Update postgres compat

JSONField now always available.

* Remove DecimalValidator compat

* Remove get_remote_field compat

* Remove template_render compat

Plus isort.

* Remove set_many compat

* Remove include compat 
tests/test_prefetch_related.py