Student Tasks¶
Practical tasks for Notes Chat App at three difficulty levels.
Level 1 — Minimal¶
Add a new field to the Note model, create and apply a migration, and show the field in the detail template.
Steps:
- Add the field in
notes_app/models.py(for example,color = models.CharField(max_length=7, default='#808080', blank=True)). - Create the migration:
docker compose run --rm web python manage.py makemigrations. - Apply it:
docker compose run --rm web python manage.py migrate. - Show the field in
templates/notes_app/note_detail.html.
Criteria:
- The migration file exists in
notes_app/migrations/. manage.py checkpasses without errors.- The template displays the field without errors.
- Existing tests pass:
docker compose run --rm web python manage.py test notes_app.tests.test_models -v 2.
Level 2 — Core¶
Add an archive/unarchive flow through a service, a view, a URL, and a test.
Steps:
Notealready has anis_archivedfield; use it.- Add a function in
notes_app/services.py(similar totoggle_pin). - Add a selector in
notes_app/selectors.pyto fetch archived notes. - Add a view in
notes_app/views.py. - Add a URL in
notes_app/urls.py. - Add a test in
notes_app/tests/test_services.pyortest_views.py.
Criteria:
- The business logic lives in
services.py(not in the view). - The read query lives in
selectors.py. - Access rules are tested (it is impossible to archive someone else's note).
- All existing tests pass.
Level 3 — Advanced¶
Restore the async HTTP demo or fix the Docker production blockers.
Option A: Async HTTP demo¶
Current state: async_views.py, async_selectors.py, async_services.py are absent from the working tree.
Implement an async view for the note list:
- Use async def note_list_async(request).
- Wrap the ORM calls with database_sync_to_async.
- Register the URL.
- Write a test.
Option B: Production Docker¶
- Move
SECRET_KEYinto an environment variable. - Add a
DEBUG=Falsemode with a correctALLOWED_HOSTS. - Remove
DebugExceptionMiddlewareor restrict it with anif settings.DEBUGcondition. - Replace
uvicorn --reloadwith a production command. - Document all the changes.
Criteria (both options):
- The command is documented.
- Tests / checks pass, or the blocker is described honestly.
- Existing features do not break.