          # You can still use latest() with a model that doesn't have
          # "get_latest_by" set -- just pass in the field name manually.
          Person.objects.create(name="Ralph", birthday=datetime(1950, 1, 1))
          p2 = Person.objects.create(name="Stephanie", birthday=datetime(1960, 2, 3))
          with self.assertRaises(AssertionError):
              Person.objects.latest()
          self.assertEqual(Person.objects.latest("birthday"), p2)
  
  
  class TestFirstLast(TestCase):
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'book_contact_set' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'age' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'Cannot force both insert and updating in model saving.'
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'friends' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'Cannot force an update in save() with no primary key.'
        with self.assertRaisesMessage(ValueError, msg):
        msg = (
            "earliest() and latest() require either a field_name parameter or "
            "'get_latest_by' in the model"
        )
        with self.assertRaisesMessage(AssertionError, msg):
          # You can still use latest() with a model that doesn't have
          # "get_latest_by" set -- just pass in the field name manually.
          Person.objects.create(name="Ralph", birthday=datetime(1950, 1, 1))
          p2 = Person.objects.create(name="Stephanie", birthday=datetime(1960, 2, 3))
        msg = (
            "earliest() and latest() require either a field_name parameter or "
            "'get_latest_by' in the model"
        )
        with self.assertRaisesMessage(AssertionError, msg):
              Person.objects.latest()
          self.assertEqual(Person.objects.latest("birthday"), p2)
  
  
  class TestFirstLast(TestCase):
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/get_earliest_or_latest/tests.py