code: def mocked_relations(*models):
      
      patchers = []
  
      for model in find_all_models(models):
          if isinstance(model.save, Mock):
              # already mocked, so skip it
              continue
  
          model_name = model._meta.object_name
          patchers.append(_patch_save(model, model_name))
  
          if hasattr(model, 'objects'):
              patchers.append(_patch_objects(model, model_name))
  
          for related_object in chain(model._meta.related_objects,
                                      model._meta.many_to_many):
              name = related_object.name
  
              if name not in model.__dict__ and related_object.one_to_many:
                  name += '_set'
  
              if name in model.__dict__:
                  # Only mock direct relations, not inherited ones.
                  if getattr(model, name, None):
                      patchers.append(_patch_relation(
                          model, name, related_object
                      ))
  
      return PatcherChain(patchers, pass_mocks=False)
docs: Mock all related field managers to make pure unit tests possible.
  
      The resulting patcher can be used just like one from the mock module:
      As a test method decorator, a test class decorator, a context manager,
      or by just calling start() and stop().
  
      @mocked_relations(Dataset):
      def test_dataset(self):
          dataset = Dataset()
          check = dataset.content_checks.create()  # returns a ContentCheck object