From a11541eb58df7336e54b98b6292b7db50369b0f4 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Tue, 5 Jul 2022 14:14:03 +0300 Subject: [PATCH] prefetch_related initial attempts --- core/views/scans.py | 6 ++++++ templates/manywallets.html | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/core/views/scans.py b/core/views/scans.py index 4b35377..097c69f 100644 --- a/core/views/scans.py +++ b/core/views/scans.py @@ -58,5 +58,11 @@ def scansingle(request, path, file): def allwallets(request): + '''Returns all the wallets in the system, we would like to use + the Django queryset SQL optimisation https://docs.djangoproject.com/en/3.2/ref/models/querysets/#prefetch-related + to get the related singlescan and survexblock objects but that requires rewriting this to do the query on those, not on + the wallets + ''' manywallets = Wallet.objects.all() + # manywallets = Wallet.objects.all().prefetch_related('singlescan') fails as the link is defined on 'singlescan' not on 'wallet' return render(request, 'manywallets.html', { 'manywallets':manywallets, 'settings': settings }) diff --git a/templates/manywallets.html b/templates/manywallets.html index 7a61dc4..46dd302 100644 --- a/templates/manywallets.html +++ b/templates/manywallets.html @@ -9,6 +9,10 @@ plans and elevations. It also contains scans of centre-line survex output on which hand-drawn passage sections are drawn. These hand-drawn passages will eventually be traced to produce Tunnel or Therion drawings and eventually the final complete cave survey. + + {% for scanswallet in manywallets %}
Scans folderFilesSurvex blocksCave