wagtail-stubs
PEP 561 type stubs for wagtail.
Custom base page models
Wagtail 8.0 lets a project replace wagtail.models.Page with its own base page model (the WAGTAIL_PAGE_MODEL setting). The stubs cannot read Django settings, so:
wagtail.models.Pageis always typed as Wagtail's ownPageclass. In a project with a custom base page model, use your own model class (orAbstractPage) instead.- Values that are "a page of whatever model the project uses", such as
GroupPagePermission.page,PageViewRestriction.page,Workflow.all_pages()orpage_permission_policy, are typed asAbstractPage.Site.root_pagestays untyped (Any) so that projects using the stockPagekeep working unchanged. - On a custom base page model, tree methods (
get_children(),get_parent(),get_descendants(), ...) returnAbstractPage/PageQuerySet[AbstractPage]. For a precise type, query through your model:BasePage.objects.child_of(page). PageQuerySet[Page].type(BlogPage)andPageQuerySet[AbstractPage].type(BlogPage)narrow toPageQuerySet[BlogPage], butPageQuerySet[BasePage].type(BlogPage)does not.PageQuerySetis invariant (its type parameter comes fromdjango-treebeard-stubs), so aPageQuerySet[Page]cannot be passed where aPageQuerySet[AbstractPage]is expected.swapperships no type information, soswapper.load_model("wagtailcore", "Page")is untyped. Annotate the result astype[AbstractPage].wagtail.contrib.sitemaps.Sitemaptakes the page model as an optional type parameter, which typesitems(),location(),lastmod()andself.paginator. Without it the page type isAny, so existing subclasses keep working unchanged. Like the admin views below, subscript it for the type checker only:_SitemapBase = Sitemap[BasePage]insideif TYPE_CHECKING:.
Generic admin views and viewsets
ModelViewSet, SnippetViewSet, ChooserViewSet, the generic admin views (wagtail.admin.views.generic), the chooser views, and the page views with PageListingViewSet / PageViewSet take the model as a type parameter. The parameter ties model, object, get_object(), get_queryset(), save_instance() and action_class to your model. Create and edit views take the form class as an optional second parameter. Without parameters, model views and viewsets default to Model, page views and viewsets default to AbstractPage, and the form defaults to WagtailAdminModelForm, so existing subclasses keep their current types.
permission_policy is not tied to the parameter. Wagtail looks it up in the policy registry, which returns the policy of the nearest registered ancestor model, so it is typed BasePermissionPolicy[Any] (or PagePermissionPolicy[AbstractPage] on page views).
Wagtail's classes do not support subscripting at runtime, so class GroupViewSet(ModelViewSet[Group]) raises TypeError. Subscript the base class for the type checker only:
from typing import TYPE_CHECKING
from django.contrib.auth.models import Group
from wagtail.admin.views.generic import EditView
from wagtail.admin.viewsets.model import ModelViewSet
if TYPE_CHECKING:
_GroupEditViewBase = EditView[Group]
_GroupViewSetBase = ModelViewSet[Group]
else:
_GroupEditViewBase = EditView
_GroupViewSetBase = ModelViewSet
class GroupEditView(_GroupEditViewBase):
def get_success_message(self) -> str | None:
return f"Saved {self.object.name}" # self.object is a Group
class GroupViewSet(_GroupViewSetBase):
model = Group
edit_view_class = GroupEditView
If you already call django_stubs_ext.monkeypatch(), you can instead pass the classes you subscript, for example django_stubs_ext.monkeypatch(extra_classes=[ModelViewSet, EditView]), and write ModelViewSet[Group] directly.
The *_view_class attributes are not tied to the viewset's parameter, because code such as PageListingViewSet.index_view_class.base_columns reads them from the class itself. Parameterize the view classes you assign to them yourself.
Metadata
Release files for wagtail-stubs 8.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wagtail_stubs-8.1.0.tar.gz | 273.6 kB | With provenance | Details for wagtail_stubs-8.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wagtail_stubs-8.1.0-py3-none-any.whl | Python 3 | none | any | Details for wagtail_stubs-8.1.0-py3-none-any.whl |
Total release size: 699.8 kB
Release files / wagtail_stubs-8.1.0.tar.gz
| Download URL | wagtail_stubs-8.1.0.tar.gz |
|---|---|
| Size | 273.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
149810526edb4649f297abca49b02f4e81e0d84f3e0741dd16c810aa2ea785c3
|
|
BLAKE2b-256 checksum How to use checksums |
f318318ffcdf01153bc78a9699b2e8ca97d013b8505da10c4235e3d884680583
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitLab CI/CD, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / wagtail_stubs-8.1.0-py3-none-any.whl
| Download URL | wagtail_stubs-8.1.0-py3-none-any.whl |
|---|---|
| Size | 426.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a860e597028c6e2e8d78dd65e92e8fc7f810e3e87ebcddcc53ac766daa4eeb48
|
|
BLAKE2b-256 checksum How to use checksums |
7dc1ee71960fb2f3d93421083d0a33bd522a896d905e379d35ee8ded46e5d526
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.14.10
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitLab CI/CD, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for wagtail-stubs 8.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for wagtail_stubs-8.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitLab CI/CD, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.