From 5bf3f7e30d9eb4797c0a5211bffa985440f1d078 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Mon, 30 Oct 2023 16:24:28 +0000 Subject: [PATCH] Move viewset intro in generic views docs to the base `ViewSet` usage docs --- docs/extending/admin_views.md | 6 ++++-- docs/extending/generic_views.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/extending/admin_views.md b/docs/extending/admin_views.md index 25b688a7ae..0b28344f06 100644 --- a/docs/extending/admin_views.md +++ b/docs/extending/admin_views.md @@ -232,7 +232,9 @@ The 'Calendar' item will now appear as a group of menu items. When expanded, the ## Using `ViewSet` to group custom admin views -Wagtail provides a {class}`~wagtail.admin.viewsets.base.ViewSet` class that combines the registration of views and the associated menu item into a single class. For example, you can group the calendar views from the previous example into a single menu item by creating a `ViewSet` subclass in `views.py`: +Registering admin views along with their URLs and menu items is a common pattern in Wagtail. This often involves several related views with shared properties such as the model that we're working with, and its associated icon. To support the pattern, Wagtail implements the concept of a _viewset_, which allows a bundle of views and their URLs to be defined collectively, along with a menu item to be registered with the admin app as a single operation through the [`register_admin_viewset`](register_admin_viewset) hook. + +For example, you can group the calendar views from the previous example into a single menu item by creating a {class}`~wagtail.admin.viewsets.base.ViewSet` subclass in `views.py`: ```{code-block} python from wagtail.admin.viewsets.base import ViewSet @@ -261,7 +263,7 @@ class CalendarViewSet(ViewSet): ] ``` -Then, remove the `register_admin_urls` and `register_admin_menu_item` hooks in `wagtail_hooks.py` in favor of registering the `ViewSet` subclass with the [`register_admin_viewset`](register_admin_viewset) hook: +Then, remove the `register_admin_urls` and `register_admin_menu_item` hooks in `wagtail_hooks.py` in favor of registering the `ViewSet` subclass with the `register_admin_viewset` hook: ```{code-block} python from .views import CalendarViewSet diff --git a/docs/extending/generic_views.md b/docs/extending/generic_views.md index fca855118c..8251587604 100644 --- a/docs/extending/generic_views.md +++ b/docs/extending/generic_views.md @@ -2,7 +2,7 @@ # Generic views -Wagtail provides several generic views for handling common tasks such as creating / editing model instances and chooser modals. Since these often involve several related views with shared properties (such as the model that we're working with, and its associated icon) Wagtail also implements the concept of a _viewset_, which allows a bundle of views to be defined collectively, and their URLs to be registered with the admin app as a single operation through the [`register_admin_viewset`](register_admin_viewset) hook. +Wagtail provides several generic views for handling common tasks such as creating / editing model instances and chooser modals. For convenience, these views are bundled in [viewsets](viewsets_reference). ## ModelViewSet