From 2fdb03cf753e602ecccc63fe52522a0851cbf929 Mon Sep 17 00:00:00 2001 From: Matthew Elwell Date: Wed, 8 Jul 2026 13:51:39 +0100 Subject: [PATCH] docs: Update README with additional code guidelines on models and django signals Added code guidelines for models and asynchronous dispatch. --- api/README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/README.md b/api/README.md index b4ca297dc0c9..f68c4566c969 100644 --- a/api/README.md +++ b/api/README.md @@ -145,3 +145,11 @@ We tend to add our own layers in the following modules: - `services.py` for encapsulated business logic. Our goal with this layer is to make the views, models and serialisers leaner, so that the business logic is more clearly defined and easier to compose. - `tasks.py` for defining asynchronous and recurring tasks. - `types.py` for custom type definitions, including typed dicts. + +### Code guidelines: models + +Avoid implementing business logic inside `models` modules. The `models` modules should act as a repository only, and business logic should be contained to `services` modules. + +### Code guidelines: asynchronous dispatch + +Avoid using lifecycle hooks and django signals where possible in favour of explicit dispatching of logic.