Django Quiz
Explain the difference between hiding a control, validating a form and enforcing a database invariant. Each layer has a useful role, and none automatically replaces the others.
Your brief
Predict the outcomes for a missing workshop, an invalid seat form and a duplicate reservation. A missing public object gives 404, an invalid form gives 400 and a duplicate booking gives a conflict after database rollback. Then explain why force_login does not test a password and why a SQLite test does not prove PostgreSQL row locking. Good answers name the boundary and stored state, not just the framework feature.
Run in the supplied local Django project
This lesson uses Django 5.2.18 LTS with Python 3.12. Download the source downloader and run node download-project.mjs http://127.0.0.1:8000 with Node 22 while previewing locally. It creates a new bhylu-django-lab folder and refuses to overwrite an existing one. After deployment, the default base is bhylu.com; until then use your local preview URL.
Inside that new folder, create a virtual environment, install requirements.txt and run the complete lesson file shown below. Every lesson creates a fresh in-memory SQLite database and temporary upload storage. It does not edit the interactive lab’s db.sqlite3 or Bhylu’s database. The visible listing below is the lesson’s core code; its complete downloaded file includes the shared bootstrap.
Django does not run in Bhylu’s current browser playground. No Apache, MySQL or global PHP configuration change is needed. See the setup lesson for the full project and commands.
Worked solution
Run .venv\Scripts\python.exe lessons\quiz.py from the downloaded project root. Download the complete lesson file; keep it under lessons/. The project’s shared models, forms, views and fixture are prerequisites, not a hidden online runtime.
Show the worked solution
from workshops.forms import SeatsForm
print(Client().get("/workshops/missing/").status_code)
print(SeatsForm({"seats":0}).is_valid())
from django.db import connection
print(connection.features.has_select_for_update)
Expected result
404 False False
The three results concern object visibility, form validity and a backend capability. They are deliberately different questions. The final false prevents a misleading claim that SQLite is exercising PostgreSQL-style row locks.
Extend and test
Explain when get raises, when a QuerySet executes, why logout is a POST and why a successful template render does not prove its stylesheet was served.
Use Django’s versioned official documentation for exact API contracts and the deployment checklist before a separate release.