3 | | {{{ |
4 | | >>> players = Player.objects.filter(id=self.player_id) |
5 | | >>> # Enable prefetching |
6 | | >>> players = players.prefetch_related('awards') |
7 | | >>> # Disable prefetching (before the queryset is evaluated) |
8 | | >>> players.prefetch_related(None) |
9 | | >>> player = players.get() |
10 | | >>> # For sqlite3, this fails with "2 != 0": |
11 | | >>> self.assertEqual(2, len(player.awards.all())) |
12 | | |
13 | | (0.000) QUERY = 'SELECT "model_fields_player"."id", "model_fields_player"."name" FROM "model_fields_player" WHERE "model_fields_player"."id" = %s' - PARAMS = ('9674a6f11c044484b89bac792e53e642',); args=('9674a6f11c044484b89bac792e53e642',) |
14 | | |
15 | | (0.000) QUERY = 'SELECT ("model_fields_player_awards"."player_id") AS "_prefetch_related_val_player_id", "model_fields_award"."id", "model_fields_award"."name" FROM "model_fields_award" INNER JOIN "model_fields_player_awards" ON ( "model_fields_award"."id" = "model_fields_player_awards"."award_id" ) WHERE "model_fields_player_awards"."player_id" IN (%s)' - PARAMS = ('9674a6f11c044484b89bac792e53e642',); args=('9674a6f11c044484b89bac792e53e642',) |
16 | | }}} |