From ba755221bbfb167352312e988c518fba3414bbbf Mon Sep 17 00:00:00 2001 From: Mattias L <156665038+mulmat@users.noreply.github.com> Date: Fri, 26 Jan 2024 20:15:28 +0100 Subject: [PATCH] Improved docs for how to register dashboard widgets (#14913) --- docs/plugins/development/dashboard-widgets.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/plugins/development/dashboard-widgets.md b/docs/plugins/development/dashboard-widgets.md index b1c9d0e45..74f9c9474 100644 --- a/docs/plugins/development/dashboard-widgets.md +++ b/docs/plugins/development/dashboard-widgets.md @@ -47,3 +47,14 @@ class ReminderWidget(DashboardWidget): def render(self, request): return self.config.get('content') ``` + +## Initialization + +To register the widget, it becomes essential to import the widget module. The recommended approach is to accomplish this within the `ready` method situated in your `PluginConfig`: + +```python +class FooBarConfig(PluginConfig): + def ready(self): + super().ready() + from . import widgets # point this to the above widget module you created +```