"""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.core.cache import cache key = "public-workshop-count:v1" cache.set(key, Workshop.objects.public().count(), timeout=60) Workshop.objects.filter(slug="wood-joints").update(published=True) print(cache.get(key), Workshop.objects.public().count()) cache.delete(key) print(cache.get(key) is None)