Skip to main content

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.Page is always typed as Wagtail's own Page class. In a project with a custom base page model, use your own model class (or AbstractPage) instead.
  • Values that are "a page of whatever model the project uses", such as GroupPagePermission.page, PageViewRestriction.page, Workflow.all_pages() or page_permission_policy, are typed as AbstractPage. Site.root_page stays untyped (Any) so that projects using the stock Page keep working unchanged.
  • On a custom base page model, tree methods (get_children(), get_parent(), get_descendants(), ...) return AbstractPage / PageQuerySet[AbstractPage]. For a precise type, query through your model: BasePage.objects.child_of(page).
  • PageQuerySet[Page].type(BlogPage) and PageQuerySet[AbstractPage].type(BlogPage) narrow to PageQuerySet[BlogPage], but PageQuerySet[BasePage].type(BlogPage) does not.
  • PageQuerySet is invariant (its type parameter comes from django-treebeard-stubs), so a PageQuerySet[Page] cannot be passed where a PageQuerySet[AbstractPage] is expected.
  • swapper ships no type information, so swapper.load_model("wagtailcore", "Page") is untyped. Annotate the result as type[AbstractPage].

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.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wagtail-stubs 8.0.0
File Size Uploaded Provenance Actions
wagtail_stubs-8.0.0.tar.gz 261.8 kB With provenance Details for wagtail_stubs-8.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wagtail-stubs 8.0.0
File Interpreter ABI Platform Actions
wagtail_stubs-8.0.0-py3-none-any.whl Python 3 none any Details for wagtail_stubs-8.0.0-py3-none-any.whl

Total release size: 683.6 kB

Release files / wagtail_stubs-8.0.0.tar.gz

Download URL wagtail_stubs-8.0.0.tar.gz
Size 261.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d863ce31730949e019c6bca62e9213c41d27235f68949538c6c2f53f366f4931
BLAKE2b-256 checksum
How to use checksums
06d2e5d43049c5dba34e0acb0da4d74ef8599686dc43cf48bdd3fb2fe993dec1
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 2, 2026.

Transparency log

Release files / wagtail_stubs-8.0.0-py3-none-any.whl

Download URL wagtail_stubs-8.0.0-py3-none-any.whl
Size 421.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff648892412cc0c109d13244840888a75b358c49c64dfd6198a9aa67739b3b13
BLAKE2b-256 checksum
How to use checksums
370c956023432a48fbe16afb4b400c10b8d40bb67f4a111b73d79f5c931064ff
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 2, 2026.

Transparency log

Security for wagtail-stubs 8.0.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.

Select from 2 files

Attestation for wagtail_stubs-8.0.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 2, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

8.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page