| 35 | Update |
| 36 | Same error I had when tested a method "get_admin_url()" of the model Book with next a testing code |
| 37 | |
| 38 | {{{ |
| 39 | def test_get_admin_url(self): |
| 40 | self.client.force_login(self.active_superuser) |
| 41 | response = self.client.get(self.book.get_admin_url()) |
| 42 | self.assertEqual(response.status_code, 200) |
| 43 | }}} |
| 44 | |
| 45 | Ending a traceback |
| 46 | |
| 47 | {{{ |
| 48 | if not num: |
| 49 | raise self.model.DoesNotExist( |
| 50 | "%s matching query does not exist." % |
| 51 | self.model._meta.object_name |
| 52 | ) |
| 53 | raise self.model.MultipleObjectsReturned( |
| 54 | "get() returned more than one %s -- it returned %s!" % |
| 55 | > (self.model._meta.object_name, num) |
| 56 | ) |
| 57 | E apps.books.models.MultipleObjectsReturned: get() returned more than one Book -- it returned 3! |
| 58 | }}} |
| 59 | |