Django Migrations
Migrations describe schema changes in versioned files. makemigrations writes a proposed change; migrate applies a dependency-ordered plan to a database.
How it works
The lab supplies an initial migration and a second migration adding the venue access note. Keep both under version control so another environment can reproduce the same schema. Review generated operations before applying them, especially for non-null fields, data loss and large tables. Do not delete migration history merely to silence a conflict; reconcile the model state and dependency graph deliberately.
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.
Example
Run .venv\Scripts\python.exe lessons\migrations.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.
from django.db import connection
from django.db.migrations.recorder import MigrationRecorder
names = list(MigrationRecorder(connection).migration_qs.filter(app="workshops").order_by("name").values_list("name", flat=True))
print(names)
print(Venue._meta.get_field("access_note").blank)
Expected result
['0001_initial', '0002_venue_access_note'] True
The migration recorder shows both supplied changes applied. The model permits a blank note, which lets existing venues acquire the new field without inventing private information or requiring immediate manual input.
Use Django’s versioned official documentation for exact API contracts and the deployment checklist before a separate release.