| 439 | def test_exclude_multi_valued_relationship(self): |
| 440 | # Only Author 3 has published an "Article_ with underscore" |
| 441 | # before 2006. |
| 442 | a8 = Article.objects.create( |
| 443 | headline='Article_ with underscore', |
| 444 | pub_date=datetime(2011, 11, 20), |
| 445 | author=self.au1) |
| 446 | a9 = Article.objects.create( |
| 447 | headline='Article_ with underscore', |
| 448 | pub_date=datetime(2011, 11, 20), |
| 449 | author=self.au2) |
| 450 | au3 = Author.objects.create(name='Author 3') |
| 451 | a10 = Article.objects.create( |
| 452 | headline='Article_ with underscore', |
| 453 | pub_date=datetime(2005, 11, 21), |
| 454 | author=au3) |
| 455 | |
| 456 | self.assertQuerysetEqual( |
| 457 | Author.objects.filter( |
| 458 | article__headline='Article_ with underscore', |
| 459 | article__pub_date__lt=datetime(2006, 1, 1)), |
| 460 | [ |
| 461 | '<Author: Author 3>', |
| 462 | ]) |
| 463 | |
| 464 | self.assertQuerysetEqual( |
| 465 | Author.objects.exclude( |
| 466 | article__headline='Article_ with underscore', |
| 467 | article__pub_date__lt=datetime(2006, 1, 1)), |
| 468 | [ |
| 469 | '<Author: Author 1>', |
| 470 | '<Author: Author 2>', |
| 471 | ]) |
| 472 | |