code: def _model_exists_step(self, model, should_exist):
      
  
      model = get_model(model)
      data = guess_types(self.hashes)
  
      queryset = model.objects
  
      try:
          existence_check = _TEST_MODEL[model]
      except KeyError:
          existence_check = test_existence
  
      failed = 0
      try:
          for hash_ in data:
              match = existence_check(queryset, hash_)
  
              if should_exist:
                  assert match, \
                      "%s does not exist: %s" % (model.__name__, hash_)
              else:
                  assert not match, \
                      "%s exists: %s" % (model.__name__, hash_)
  
      except AssertionError as exc:
          print(exc)
          failed += 1
  
      if failed:
          print("Rows in DB are:")
          for existing_model in queryset.all():
              _dump_model(existing_model,
                          attrs=[k[1:]
                                 for k in data[0].keys()
                                 if k.startswith('@')])
  
          if should_exist:
              raise AssertionError("%i rows missing" % failed)
          else:
              raise AssertionError("%i rows found" % failed)
docs: Test for the existence of a model matching the given data.