"""Run from the supplied project's lessons folder; data is temporary.""" from pathlib import Path import sys lesson_folder = Path(__file__).resolve().parent # A lesson filename must not shadow an installed package such as whitenoise. sys.path = [entry for entry in sys.path if Path(entry or ".").resolve() != lesson_folder] sys.path.insert(0, str(lesson_folder.parent)) from lab_support import start start() from workshops.models import Venue, Workshop, Reservation from django.test import Client, RequestFactory, override_settings # Lesson code: the shared lab is ready, with three fictional workshops. from django.db import connection from django.test.utils import CaptureQueriesContext with CaptureQueriesContext(connection) as queries: rows = Workshop.objects.filter(published=True) print(len(queries)) titles = list(rows.values_list("title", flat=True)) print(len(queries)) print(titles)