Improve linking between viewset reference and extending docs

pull/11170/head
Sage Abdullah 2023-10-30 15:24:52 +00:00 zatwierdzone przez Matt Westcott
rodzic 3032ea2e3b
commit 43e306a49b
4 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -1,10 +1,12 @@
(generic_views)=
# 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.
## ModelViewSet
The `wagtail.admin.viewsets.model.ModelViewSet` class provides the views for listing, creating, editing, and deleting model instances. For example, if we have the following model:
The {class}`wagtail.admin.viewsets.model.ModelViewSet` class provides the views for listing, creating, editing, and deleting model instances. For example, if we have the following model:
```python
from django.db import models

Wyświetl plik

@ -2,7 +2,7 @@
# Viewsets
Viewsets are Wagtail's mechanism for defining a group of related admin views with shared properties, as a single unit. See [Generic views](../extending/generic_views).
Viewsets are Wagtail's mechanism for defining a group of related admin views with shared properties, as a single unit.
## ViewSet

Wyświetl plik

@ -11,8 +11,10 @@ class ViewSet(WagtailMenuRegisterable):
All properties of the viewset can be defined as class-level attributes, or passed as
keyword arguments to the constructor (in which case they will override any class-level
attributes). Additionally, the `name` property can be passed as the first positional
attributes). Additionally, the ``name`` property can be passed as the first positional
argument to the constructor.
For more information on how to use this class, see :ref:`using_base_viewset`.
"""
#: A name for this viewset, used as the default URL prefix and namespace.
@ -133,6 +135,8 @@ class ViewSetGroup(WagtailMenuRegisterableGroup):
"""
A container for grouping together multiple ViewSet instances.
Creates a menu item with a submenu for accessing the main URL for each instances.
For more information on how to use this class, see :ref:`using_base_viewsetgroup`.
"""
def on_register(self):

Wyświetl plik

@ -25,6 +25,8 @@ class ModelViewSet(ViewSet):
All attributes and methods from :class:`~wagtail.admin.viewsets.base.ViewSet`
are available.
For more information on how to use this class, see :ref:`generic_views`.
"""
#: Register the model to the reference index to track its usage.