          a1 = Article.objects.create(pub_date=datetime.date.today())
          ArticleTag.objects.create(article=a1, name="foo")
          self.assertEqual(Article.objects.filter(tag__name="foo").count(), 1)
          self.assertEqual(Article.objects.filter(tag__name="bar").count(), 0)
          with self.assertRaises(FieldError):
              Article.objects.filter(tags__name="foo")
  
      def test_many_to_many_related_query_name(self):
          a1 = Article.objects.create(pub_date=datetime.date.today())
          i1 = ArticleIdea.objects.create(name="idea1")
 
</s> remove         with self.assertRaises(FieldError):
 </s> add         msg = (
            "Cannot resolve keyword 'ideas' into field. Choices are: "
            "active_translation, active_translation_q, articletranslation, "
            "id, idea_things, newsarticle, pub_date, tag"
        )
        with self.assertRaisesMessage(FieldError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         with self.assertRaisesMessage(ValueError, self.msg % 'accounts'): </s> remove         with self.assertRaises(TypeError):
 </s> add         msg = 'Cannot call delete() after .values() or .values_list()'
        with self.assertRaisesMessage(TypeError, msg): </s> remove         with self.assertRaises(FieldError):
 </s> add         msg = "Unsupported lookup 'blahblah' for CharField or join on the field not permitted."
        with self.assertRaisesMessage(FieldError, msg): </s> remove             with self.assertRaises(FieldError):
 </s> add             msg = "Joined field references are not permitted in this query"
            with self.assertRaisesMessage(FieldError, msg):
        msg = (
            "Cannot resolve keyword 'tags' into field. Choices are: "
            "active_translation, active_translation_q, articletranslation, "
            "id, idea_things, newsarticle, pub_date, tag"
        )
        with self.assertRaisesMessage(FieldError, msg):
          a1 = Article.objects.create(pub_date=datetime.date.today())
          ArticleTag.objects.create(article=a1, name="foo")
          self.assertEqual(Article.objects.filter(tag__name="foo").count(), 1)
          self.assertEqual(Article.objects.filter(tag__name="bar").count(), 0)
        msg = (
            "Cannot resolve keyword 'tags' into field. Choices are: "
            "active_translation, active_translation_q, articletranslation, "
            "id, idea_things, newsarticle, pub_date, tag"
        )
        with self.assertRaisesMessage(FieldError, msg):
              Article.objects.filter(tags__name="foo")
  
      def test_many_to_many_related_query_name(self):
          a1 = Article.objects.create(pub_date=datetime.date.today())
          i1 = ArticleIdea.objects.create(name="idea1")
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/foreign_object/tests.py