Skip to content

Commit

Permalink
Add docs for migrating ModelAdminGroup to SnippetViewSetGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
laymonage committed Aug 10, 2023
1 parent fd2a429 commit 133da4c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/reference/contrib/modeladmin/migrating_to_snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,28 @@ There are a few attributes of `ModelAdmin` that need to be renamed/adjusted for
| `form_fields_exclude` | {attr}`~wagtail.admin.viewsets.model.ModelViewSet.exclude_form_fields` | Same value, but different attribute name to better align with `ModelViewSet`. |
| - | {attr}`~SnippetViewSet.template_prefix` | New attribute. Set to the name of a template directory to override the `"wagtailsnippets/snippets/"` default. If set to `"modeladmin/"`, the template directory structure will be equal to what ModelAdmin uses. Make sure any custom templates are placed in the correct directory according to this prefix. See [](wagtailsnippets_templates) for more details. |

## Convert `ModelAdminGroup` class to `SnippetViewSetGroup`

The {class}`~SnippetViewSetGroup` class is the snippets-equivalent to the `ModelAdminGroup` class. To migrate a `ModelAdminGroup` class to a `SnippetViewSetGroup` class, follow these instructions.

Change any imports of `ModelAdminGroup` to `SnippetViewSetGroup`:

```diff
- from wagtail.contrib.modeladmin.options import ModelAdminGroup
+ from wagtail.snippets.views.snippets import SnippetViewSetGroup
```

Change any references to `ModelAdminGroup` to `SnippetViewSetGroup`:

```diff
- class MyModelAdminGroup(ModelAdminGroup):
+ class MySnippetViewSetGroup(SnippetViewSetGroup):
...

- modeladmin_register(MyModelAdminGroup)
+ register_snippet(MySnippetViewSetGroup)
```

## Unsupported features and customizations

Some features and customizations in `ModelAdmin` are not directly supported via `SnippetViewSet`, but may be achievable via other means that are more in line with Wagtail's architecture.
Expand Down

0 comments on commit 133da4c

Please sign in to comment.