From 64e56cd7c84b80fb78a293ba9cc6a5100c99b589 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 26 Nov 2024 10:35:30 -0500 Subject: [PATCH] #16971: Improve example in documentation --- docs/plugins/development/background-jobs.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/plugins/development/background-jobs.md b/docs/plugins/development/background-jobs.md index d51981b9e0d..3d789b6b92d 100644 --- a/docs/plugins/development/background-jobs.md +++ b/docs/plugins/development/background-jobs.md @@ -87,14 +87,17 @@ class MyHousekeepingJob(JobRunner): def run(self, *args, **kwargs): MyModel.objects.filter(foo='bar').delete() - -system_jobs = ( - MyHousekeepingJob, -) ``` !!! note - Ensure that any system jobs are imported on initialization. Otherwise, they won't be registered. This can be achieved by extending the PluginConfig's `ready()` method. + Ensure that any system jobs are imported on initialization. Otherwise, they won't be registered. This can be achieved by extending the PluginConfig's `ready()` method. For example: + + ```python + def ready(self): + super().ready() + + from .jobs import MyHousekeepingJob + ``` ## Task queues