bhylu.com

Advertisements

Django Study Plan

Build one understandable workflow before adding more packages or cloud services. Keep a repeatable fixture and a short list of invariants beside your code.

Your brief

Begin with the local setup and route a plain response. Add a readable list and detail page, then models and migrations. Learn query behaviour before building reports, and validate forms before accepting writes. Add authentication, ownership, rollback tests and CSRF checks before considering hosting. PostgreSQL, async interfaces and cloud infrastructure should answer an actual requirement rather than become an automatic beginner checklist.

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\study-plan.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
lessons/study-plan.py — core code

checks = {
    "public workshops": Workshop.objects.public().count() == 2,
    "draft hidden": Client().get("/workshops/wood-joints/").status_code == 404,
    "no bookings yet": Reservation.objects.count() == 0,
}
for name, passed in checks.items():
    print(name + ": " + ("pass" if passed else "fail"))

Expected result

public workshops: pass
draft hidden: pass
no bookings yet: pass

The checklist records the starting state used throughout the course. Expand it with a successful booking and each meaningful rejection. Keep the expected results written down so a changed fixture does not silently change what a test is intended to prove.

Extend and test

Build your own two-workshop fixture and predict its report. Add one rejection test for every field and permission boundary your change introduces.

Use Django’s versioned official documentation for exact API contracts and the deployment checklist before a separate release.

Advertisements