Просмотр исходного кода

Improved docs for how to register dashboard widgets (#14913)

Mattias L 2 лет назад
Родитель
Сommit
ba755221bb
1 измененных файлов с 11 добавлено и 0 удалено
  1. 11 0
      docs/plugins/development/dashboard-widgets.md

+ 11 - 0
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
+```