From 864c71a735ca82dc2e9c9c2c6f9eab0fae4a3d1b Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 24 Feb 2021 15:08:45 +0000 Subject: [PATCH] api: do not fetch every patch in a patch detail view 404 (v2) Commit 08c5856 fixed an issue whereby a 404 on the aforementioned URL could result in a large DB query due to DRF attempting to populate the 'related' list box with all patches on the instance. That was accidentally reverted in commit fe07f30. "Unrevert" this change. Signed-off-by: Stephen Finucane Fixes: fe07f30 ("Remove 'PatchRelationSerializer'") Closes: #397 (cherry picked from commit 79700f321335a2d7c649eb03932797af521942a0) --- patchwork/api/patch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patchwork/api/patch.py b/patchwork/api/patch.py index 548d2c26..c94e2a7d 100644 --- a/patchwork/api/patch.py +++ b/patchwork/api/patch.py @@ -84,7 +84,8 @@ class PatchListSerializer(BaseHyperlinkedModelSerializer): checks = SerializerMethodField() tags = SerializerMethodField() related = PatchSerializer( - source='related.patches', many=True, default=[]) + source='related.patches', many=True, default=[], + style={'base_template': 'input.html'}) def get_web_url(self, instance): request = self.context.get('request') -- 2.47.3