diff --git a/lemarche/www/dashboard_favorites/tests.py b/lemarche/www/dashboard_favorites/tests.py index 286a3ae48..9e39909ea 100644 --- a/lemarche/www/dashboard_favorites/tests.py +++ b/lemarche/www/dashboard_favorites/tests.py @@ -34,5 +34,8 @@ def test_only_favorite_list_user_can_view_favorite_list_detail(self): # favorite list user self.client.force_login(self.user_favorite_list) url = reverse("dashboard_favorites:list_detail", args=[self.favorite_list_1.slug]) - response = self.client.get(url) - self.assertEqual(response.status_code, 200) + + # check number of queries + with self.assertNumQueries(6): + response = self.client.get(url) + self.assertEqual(response.status_code, 200) diff --git a/lemarche/www/dashboard_favorites/views.py b/lemarche/www/dashboard_favorites/views.py index d2c843ba0..294571be8 100644 --- a/lemarche/www/dashboard_favorites/views.py +++ b/lemarche/www/dashboard_favorites/views.py @@ -64,7 +64,7 @@ def get_success_message(self, cleaned_data): class DashboardFavoriteListDetailView(FavoriteListOwnerRequiredMixin, DetailView): template_name = "favorites/dashboard_favorite_list_detail.html" - queryset = FavoriteList.objects.prefetch_related("siaes").all() + queryset = FavoriteList.objects.prefetch_related("siaes", "siaes__activities__sector_group").all() context_object_name = "favorite_list" def get_context_data(self, **kwargs):