| 1951 | self.assertEqual(list(qs.values_list("title", flat=True)), ["Dive into Python"]) |
| 1952 | |
| 1953 | def test_deferred_models(self): |
| 1954 | mark_def = Person.objects.using("default").create(name="Mark Pilgrim") |
| 1955 | mark_other = Person.objects.using("other").create(name="Mark Pilgrim") |
| 1956 | orig_b = Book.objects.using("other").create( |
| 1957 | title="Dive into Python", |
| 1958 | published=datetime.date(2009, 5, 4), |
| 1959 | editor=mark_other, |
| 1960 | ) |
| 1961 | b = Book.objects.using("other").only("title").get(pk=orig_b.pk) |
| 1962 | self.assertEqual(b.published, datetime.date(2009, 5, 4)) |
| 1963 | b = Book.objects.using("other").only("title").get(pk=orig_b.pk) |
| 1964 | b.editor = mark_def |
| 1965 | b.save(using="default") |
| 1966 | self.assertEqual( |
| 1967 | Book.objects.using("default").get(pk=b.pk).published, |
| 1968 | datetime.date(2009, 5, 4), |
| 1969 | ) |
| 1970 | |
| 1971 | |
| 1972 | @override_settings(DATABASE_ROUTERS=[AuthRouter()]) |