Move wagtail.core to wagtail

pull/8163/head
Karl Hobley 2022-03-17 14:38:02 +00:00 zatwierdzone przez Matt Westcott
rodzic 0fd99886a2
commit 75cc7da38a
638 zmienionych plików z 1048 dodań i 1089 usunięć

Wyświetl plik

@ -65,7 +65,7 @@ Apps (``settings.py``)
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'taggit',
'modelcluster',
@ -83,7 +83,7 @@ Wagtail requires several Django app modules, third-party apps, and defines sever
Wagtail Apps
------------
``wagtail.core``
``wagtail``
The core functionality of Wagtail, such as the ``Page`` class, the Wagtail tree, and model fields.
``wagtail.admin``
@ -138,7 +138,7 @@ URL Patterns
from django.contrib import admin
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls
@ -201,7 +201,7 @@ These two files should reside in your project directory (``myproject/myproject/`
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'taggit',
'modelcluster',
@ -374,7 +374,7 @@ These two files should reside in your project directory (``myproject/myproject/`
from django.conf import settings
import os.path
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.documents import urls as wagtaildocs_urls

Wyświetl plik

@ -121,7 +121,7 @@ invokes the ``activate_amp_mode`` context manager:
# <app>/amp_views.py
from django.template.response import SimpleTemplateResponse
from wagtail.core.views import serve as wagtail_serve
from wagtail.views import serve as wagtail_serve
from .amp_utils import activate_amp_mode
@ -142,7 +142,7 @@ Then we need to create a ``amp_urls.py`` file in the same app:
# <app>/amp_urls.py
from django.urls import re_path
from wagtail.core.urls import serve_pattern
from wagtail.urls import serve_pattern
from . import amp_views

Wyświetl plik

@ -13,7 +13,7 @@ You need to create a ``templates/wagtailadmin/`` folder within one of your apps
'dashboard',
'wagtail.core',
'wagtail',
'wagtail.admin',
# ...

Wyświetl plik

@ -38,11 +38,11 @@ As standard, Wagtail organises panels for pages into three tabs: 'Content', 'Pro
Rich Text (HTML)
~~~~~~~~~~~~~~~~
Wagtail provides a general-purpose WYSIWYG editor for creating rich text content (HTML) and embedding media such as images, video, and documents. To include this in your models, use the :class:`~wagtail.core.fields.RichTextField` function when defining a model field:
Wagtail provides a general-purpose WYSIWYG editor for creating rich text content (HTML) and embedding media such as images, video, and documents. To include this in your models, use the :class:`~wagtail.fields.RichTextField` function when defining a model field:
.. code-block:: python
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
@ -53,9 +53,9 @@ Wagtail provides a general-purpose WYSIWYG editor for creating rich text content
FieldPanel('body', classname="full"),
]
:class:`~wagtail.core.fields.RichTextField` inherits from Django's basic ``TextField`` field, so you can pass any field parameters into :class:`~wagtail.core.fields.RichTextField` as if using a normal Django field. This field does not need a special panel and can be defined with ``FieldPanel``.
:class:`~wagtail.fields.RichTextField` inherits from Django's basic ``TextField`` field, so you can pass any field parameters into :class:`~wagtail.fields.RichTextField` as if using a normal Django field. This field does not need a special panel and can be defined with ``FieldPanel``.
However, template output from :class:`~wagtail.core.fields.RichTextField` is special and needs to be filtered in order to preserve embedded content. See :ref:`rich-text-filter`.
However, template output from :class:`~wagtail.fields.RichTextField` is special and needs to be filtered in order to preserve embedded content. See :ref:`rich-text-filter`.
.. _rich_text_features:
@ -102,7 +102,7 @@ The process for creating new features is described in the following pages:
Image Formats in the Rich Text Editor
-------------------------------------
On loading, Wagtail will search for any app with the file ``image_formats.py`` and execute the contents. This provides a way to customise the formatting options shown to the editor when inserting images in the :class:`~wagtail.core.fields.RichTextField` editor.
On loading, Wagtail will search for any app with the file ``image_formats.py`` and execute the contents. This provides a way to customise the formatting options shown to the editor when inserting images in the :class:`~wagtail.fields.RichTextField` editor.
As an example, add a "thumbnail" format:
@ -120,7 +120,7 @@ To begin, import the ``Format`` class, ``register_image_format`` function, and o
The unique key used to identify the format. To unregister this format, call ``unregister_image_format`` with this string as the only argument.
``label``
The label used in the chooser form when inserting the image into the :class:`~wagtail.core.fields.RichTextField`.
The label used in the chooser form when inserting the image into the :class:`~wagtail.fields.RichTextField`.
``classnames``
The string to assign to the ``class`` attribute of the generated ``<img>`` tag.
@ -162,7 +162,7 @@ or to add custom validation logic for your models:
import geocoder # not in Wagtail, for example only - https://geocoder.readthedocs.io/
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.core.models import Page
from wagtail.models import Page
class EventPageForm(WagtailAdminPageForm):

Wyświetl plik

@ -123,8 +123,8 @@ First, we define a telepath adapter for ``AddressBlock``, so that it uses our ow
.. code-block:: python
from wagtail.core.blocks.struct_block import StructBlockAdapter
from wagtail.core.telepath import register
from wagtail.blocks.struct_block import StructBlockAdapter
from wagtail.telepath import register
from django import forms
from django.utils.functional import cached_property
@ -173,7 +173,7 @@ Here ``'myapp.blocks.AddressBlock'`` is the identifier for our JavaScript class
Additional methods and properties on ``StructBlock`` values
-----------------------------------------------------------
When rendering StreamField content on a template, StructBlock values are represented as ``dict``-like objects where the keys correspond to the names of the child blocks. Specifically, these values are instances of the class ``wagtail.core.blocks.StructValue``.
When rendering StreamField content on a template, StructBlock values are represented as ``dict``-like objects where the keys correspond to the names of the child blocks. Specifically, these values are instances of the class ``wagtail.blocks.StructValue``.
Sometimes, it's desirable to make additional methods or properties available on this object. For example, given a StructBlock that represents either an internal or external link:
@ -205,7 +205,7 @@ Instead, you should define a subclass of ``StructValue`` that implements your cu
.. code-block:: python
from wagtail.core.blocks import StructValue
from wagtail.blocks import StructValue
class LinkStructValue(StructValue):
@ -246,7 +246,7 @@ Custom block types
If you need to implement a custom UI, or handle a datatype that is not provided by Wagtail's built-in block types (and cannot be built up as a structure of existing fields), it is possible to define your own custom block types. For further guidance, refer to the source code of Wagtail's built-in block classes.
For block types that simply wrap an existing Django form field, Wagtail provides an abstract class ``wagtail.core.blocks.FieldBlock`` as a helper. Subclasses should set a ``field`` property that returns the form field object:
For block types that simply wrap an existing Django form field, Wagtail provides an abstract class ``wagtail.blocks.FieldBlock`` as a helper. Subclasses should set a ``field`` property that returns the form field object:
.. code-block:: python

Wyświetl plik

@ -36,7 +36,7 @@ See MDN for more information about [custom JavasScript events](https://developer
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_global_admin_js")
@ -64,7 +64,7 @@ Using the [`insert_editor_js` hook](../../reference/hooks.html#insert-editor-js)
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_editor_js")
@ -90,7 +90,7 @@ def get_global_admin_js():
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_global_admin_js")

Wyświetl plik

@ -302,7 +302,7 @@ this and you can write your own logic if you need to.
All Wagtail needs is the language to be activated (using Django's
``django.utils.translation.activate`` function) before the
``wagtail.core.views.serve`` view is called.
``wagtail.views.serve`` view is called.
Recipes for internationalised sites
-----------------------------------
@ -477,7 +477,7 @@ For more information, see :ref:`apiv2_i18n_filters`.
Translatable snippets
^^^^^^^^^^^^^^^^^^^^^
You can make a snippet translatable by making it inherit from ``wagtail.core.models.TranslatableMixin``.
You can make a snippet translatable by making it inherit from ``wagtail.models.TranslatableMixin``.
For example:
.. code-block:: python
@ -486,7 +486,7 @@ For example:
from django.db import models
from wagtail.core.models import TranslatableMixin
from wagtail.models import TranslatableMixin
from wagtail.snippets.models import register_snippet
@ -522,7 +522,7 @@ This will add the two fields without any constraints:
from django.db import models
from wagtail.core.models import BootstrapTranslatableMixin
from wagtail.models import BootstrapTranslatableMixin
from wagtail.snippets.models import register_snippet
@ -553,7 +553,7 @@ in that app:
.. code-block:: python
from django.db import migrations
from wagtail.core.models import BootstrapTranslatableModel
from wagtail.models import BootstrapTranslatableModel
class Migration(migrations.Migration):
dependencies = [
@ -579,7 +579,7 @@ constraints:
# myapp/models.py
from wagtail.core.models import TranslatableMixin # Change this line
from wagtail.models import TranslatableMixin # Change this line
@register_snippet
class Advert(TranslatableMixin, models.Model): # Change this line

Wyświetl plik

@ -36,7 +36,7 @@ See MDN for more information about [custom JavasScript events](https://developer
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_global_admin_js")
@ -63,7 +63,7 @@ Using the [`insert_editor_js` hook](../../reference/hooks.html#insert-editor-js)
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_editor_js")
@ -89,7 +89,7 @@ def get_global_admin_js():
# wagtail_hooks.py
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("insert_global_admin_js")

Wyświetl plik

@ -13,7 +13,7 @@ Multi-site is a Wagtail project configuration where content creators go into a s
Multi-site configuration is a single code base, on a single server, connecting to a single database. Media is stored in a single media root directory. Content can be shared between sites.
Wagtail supports multi-site out of the box: Wagtail comes with a :class:`site model <wagtail.core.models.Site>`. The site model contains a hostname, port, and root page field. When a URL is requested, the request comes in, the domain name and port are taken from the request object to look up the correct site object. The root page is used as starting point to resolve the URL and serve the correct page.
Wagtail supports multi-site out of the box: Wagtail comes with a :class:`site model <wagtail.models.Site>`. The site model contains a hostname, port, and root page field. When a URL is requested, the request comes in, the domain name and port are taken from the request object to look up the correct site object. The root page is used as starting point to resolve the URL and serve the correct page.
Wagtail also comes with :ref:`site settings <settings>`. *Site settings* are 'singletons' that let you store additional information on a site. For example, social media settings, a field to upload a logo, or a choice field to select a theme.

Wyświetl plik

@ -76,10 +76,10 @@ an argument to ``runtests.py`` or ``tox``:
.. code-block:: console
$ # Running in the current environment
$ python runtests.py wagtail.core
$ python runtests.py wagtail
$ # Running in a specified Tox environment
$ tox -e py39-dj32-sqlite-noelasticsearch wagtail.core
$ tox -e py39-dj32-sqlite-noelasticsearch wagtail
$ # See a list of available Tox environments
$ tox -l
@ -90,10 +90,10 @@ an argument to ``runtests.py``
.. code-block:: console
$ # Running in the current environment
$ python runtests.py wagtail.core.tests.test_blocks.TestIntegerBlock
$ python runtests.py wagtail.tests.test_blocks.TestIntegerBlock
$ # Running in a specified Tox environment
$ tox -e py39-dj32-sqlite-noelasticsearch wagtail.core.tests.test_blocks.TestIntegerBlock
$ tox -e py39-dj32-sqlite-noelasticsearch wagtail.tests.test_blocks.TestIntegerBlock
Running migrations for the test app models
------------------------------------------

Wyświetl plik

@ -77,7 +77,7 @@ Make sure to include the correct language code for syntax highlighting, and to f
```python
INSTALLED_APPS = [
...
"wagtail.core",
"wagtail",
...
]
```
@ -193,7 +193,7 @@ Images are hard to keep up-to-date as documentation evolves, but can be worthwhi
With its [autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html) feature, Sphinx supports writing documentation in Python docstrings for subsequent integration in the projects documentation pages. This is a very powerful feature which we highly recommend using to document Wagtails APIs.
```{eval-rst}
.. module:: wagtail.core.coreutils
.. module:: wagtail.coreutils
.. autofunction:: cautious_slugify
```
@ -202,7 +202,7 @@ With its [autodoc](https://www.sphinx-doc.org/en/master/usage/extensions/autodoc
<summary>Rendered output</summary>
```{eval-rst}
.. module:: wagtail.core.coreutils
.. module:: wagtail.coreutils
.. autofunction:: cautious_slugify
```

Wyświetl plik

@ -34,7 +34,7 @@ This retrieves the queryset of pages for your report. For our example:
# <project>/views.py
from wagtail.admin.views.reports import PageReportView
from wagtail.core.models import Page
from wagtail.models import Page
class UnpublishedChangesReportView(PageReportView):
@ -164,7 +164,7 @@ url for the report, you will need to use the ``register_admin_urls`` hook (see :
from django.urls import path, reverse
from wagtail.admin.menu import AdminOnlyMenuItem
from wagtail.core import hooks
from wagtail import hooks
from .views import UnpublishedChangesReportView
@ -190,7 +190,7 @@ The full code
# <project>/views.py
from wagtail.admin.views.reports import PageReportView
from wagtail.core.models import Page
from wagtail.models import Page
class UnpublishedChangesReportView(PageReportView):
@ -212,7 +212,7 @@ The full code
from django.urls import path, reverse
from wagtail.admin.menu import AdminOnlyMenuItem
from wagtail.core import hooks
from wagtail import hooks
from .views import UnpublishedChangesReportView

Wyświetl plik

@ -40,7 +40,7 @@ Create a ``wagtail_hooks.py`` file within the ``wagtailcalendar`` app containing
.. code-block:: python
from django.urls import path
from wagtail.core import hooks
from wagtail import hooks
from .views import index
@ -127,7 +127,7 @@ Our calendar view is now complete, but there's no way to reach it from the rest
from django.urls import path, reverse
from wagtail.admin.menu import MenuItem
from wagtail.core import hooks
from wagtail import hooks
from .views import index
@ -184,7 +184,7 @@ We also need to update ``wagtail_hooks.py`` to register our URL in the admin int
:emphasize-lines: 11
from django.urls import path
from wagtail.core import hooks
from wagtail import hooks
from .views import index, month
@ -211,7 +211,7 @@ Finally we can alter our ``wagtail_hooks.py`` to include a group of custom menu
from wagtail.admin.menu import MenuItem, SubmenuMenuItem
from wagtail.contrib.modeladmin.menus import SubMenu
from wagtail.core import hooks
from wagtail import hooks
from .views import index, month

Wyświetl plik

@ -13,7 +13,7 @@ The audit log-driven Page history replaces the revisions list page, but provide
.. note:: The audit log does not replace revisions.
The ``wagtail.core.log_actions.log`` function can be used to add logging to your own code.
The ``wagtail.log_actions.log`` function can be used to add logging to your own code.
.. function:: log(instance, action, user=None, uuid=None, title=None, data=None)
@ -33,7 +33,7 @@ The ``wagtail.core.log_actions.log`` function can be used to add logging to your
.. code-block:: python
# mypackage/views.py
from wagtail.core.log_actions import log
from wagtail.log_actions import log
def copy_for_translation(page):
# ...
@ -95,12 +95,12 @@ Action Notes
Log context
~~~~~~~~~~~
The ``wagtail.core.log_actions`` module provides a context manager to simplify code that logs a large number of actions,
The ``wagtail.log_actions`` module provides a context manager to simplify code that logs a large number of actions,
such as import scripts:
.. code-block:: python
from wagtail.core.log_actions import LogContext
from wagtail.log_actions import LogContext
with LogContext(user=User.objects.get(username='admin')):
# ...
@ -116,13 +116,13 @@ is created automatically for views within the Wagtail admin.
Log models
~~~~~~~~~~
Logs are stored in the database via the models ``wagtail.core.models.PageLogEntry`` (for actions on Page instances) and
``wagtail.core.models.ModelLogEntry`` (for actions on all other models). Page logs are stored in their own model to
Logs are stored in the database via the models ``wagtail.models.PageLogEntry`` (for actions on Page instances) and
``wagtail.models.ModelLogEntry`` (for actions on all other models). Page logs are stored in their own model to
ensure that reports can be filtered according to the current user's permissions, which could not be done efficiently
with a generic foreign key.
If your own models have complex reporting requirements that would make ``ModelLogEntry`` unsuitable, you can configure
them to be logged to their own log model; this is done by subclassing the abstract ``wagtail.core.models.BaseLogEntry``
them to be logged to their own log model; this is done by subclassing the abstract ``wagtail.models.BaseLogEntry``
model, and registering that model with the log registry's ``register_model`` method:
.. code-block:: python

Wyświetl plik

@ -33,7 +33,7 @@ Here is an example of how to add a new form that operates on the user model:
# hooks.py
from wagtail.admin.views.account import BaseSettingsPanel
from wagtail.core import hooks
from wagtail import hooks
from .forms import CustomSettingsForm
@hooks.register('register_account_settings_panel')
@ -79,7 +79,7 @@ To add a panel that alters data on the user's :class:`~wagtail.users.models.User
# hooks.py
from wagtail.admin.views.account import BaseSettingsPanel
from wagtail.core import hooks
from wagtail import hooks
from .forms import CustomProfileSettingsForm
@hooks.register('register_account_settings_panel')
@ -101,7 +101,7 @@ You can define a new tab using the ``SettingsTab`` class:
# hooks.py
from wagtail.admin.views.account import BaseSettingsPanel, SettingsTab
from wagtail.core import hooks
from wagtail import hooks
from .forms import CustomSettingsForm
custom_tab = SettingsTab('custom', "Custom settings", order=300)
@ -131,7 +131,7 @@ You can provide a custom template for the panel by specifying a template name:
# hooks.py
from wagtail.admin.views.account import BaseSettingsPanel
from wagtail.core import hooks
from wagtail import hooks
from .forms import CustomSettingsForm
@hooks.register('register_account_settings_panel')

Wyświetl plik

@ -12,7 +12,7 @@ Registering a custom bulk action
.. code-block:: python
from wagtail.admin.views.bulk_action import BulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_bulk_action')
@ -171,7 +171,7 @@ Basic example
.. code-block:: python
from wagtail.admin.views.pages.bulk_actions.page_bulk_action import PageBulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_bulk_action')
@ -192,7 +192,7 @@ Basic example
.. code-block:: python
from wagtail.images.views.bulk_actions.image_bulk_action import ImageBulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_bulk_action')
@ -213,7 +213,7 @@ Basic example
.. code-block:: python
from wagtail.documents.views.bulk_actions.document_bulk_action import DocumentBulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_bulk_action')
@ -234,7 +234,7 @@ Basic example
.. code-block:: python
from wagtail.users.views.bulk_actions.user_bulk_action import UserBulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_bulk_action')

Wyświetl plik

@ -17,7 +17,7 @@ All custom tasks must be models inheriting from ``wagtailcore.Task``. In this se
# <project>/models.py
from wagtail.core.models import Task
from wagtail.models import Task
class UserApprovalTask(Task):
@ -36,7 +36,7 @@ For example:
from django.conf import settings
from django.db import models
from wagtail.core.models import Task
from wagtail.models import Task
class UserApprovalTask(Task):
@ -54,7 +54,7 @@ can be added to ``admin_form_readonly_on_edit_fields``. For example:
from django.conf import settings
from django.db import models
from wagtail.core.models import Task
from wagtail.models import Task
class UserApprovalTask(Task):
@ -76,7 +76,7 @@ Wagtail will choose a default form widget to use based on the field type. But yo
from django.conf import settings
from django.db import models
from wagtail.core.models import Task
from wagtail.models import Task
from .widgets import CustomUserChooserWidget
@ -102,7 +102,7 @@ also be subclassed equivalently to ``Task``:
# <project>/models.py
from wagtail.core.models import TaskState
from wagtail.models import TaskState
class UserApprovalTaskState(TaskState):
@ -116,7 +116,7 @@ Your custom task must then be instructed to generate an instance of your custom
from django.conf import settings
from django.db import models
from wagtail.core.models import Task, TaskState
from wagtail.models import Task, TaskState
class UserApprovalTaskState(TaskState):
@ -245,7 +245,7 @@ As an example, we'll add email notifications for when our new task is started.
# <project>/mail.py
from wagtail.admin.mail import EmailNotificationMixin, Notifier
from wagtail.core.models import TaskState
from wagtail.models import TaskState
from .models import UserApprovalTaskState
@ -293,7 +293,7 @@ Next, you need to instantiate the notifier, and connect it to the ``task_submitt
# <project>/signal_handlers.py
from wagtail.core.signals import task_submitted
from wagtail.signals import task_submitted
from .mail import UserApprovalTaskStateSubmissionEmailNotifier

Wyświetl plik

@ -15,7 +15,7 @@ All of these plugins are created with a similar baseline, which we can demonstra
import wagtail.admin.rich_text.editors.draftail.features as draftail_features
from wagtail.admin.rich_text.converters.html_to_contentstate import InlineStyleElementHandler
from wagtail.core import hooks
from wagtail import hooks
# 1. Use the register_rich_text_features hook.
@hooks.register('register_rich_text_features')

Wyświetl plik

@ -63,7 +63,7 @@ Any app within your project can define extensions to Wagtail's rich text handlin
# my_app/wagtail_hooks.py
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_rich_text_features')
def register_my_feature(features):
@ -79,7 +79,7 @@ Rewrite handlers are classes that know how to translate the content of rich text
Rewrite handlers can also provide other useful information about rich text tags. For example, given an appropriate tag, ``PageLinkHandler`` can be used to extract which page is being referred to. This can be useful for downstream code that may want information about objects being referenced in rich text.
You can create custom rewrite handlers to support your own new ``linktype`` and ``embedtype`` tags. New handlers must be Python classes that inherit from either ``wagtail.core.richtext.LinkHandler`` or ``wagtail.core.richtext.EmbedHandler``. Your new classes should override at least some of the following methods (listed here for ``LinkHandler``, although ``EmbedHandler`` has an identical signature):
You can create custom rewrite handlers to support your own new ``linktype`` and ``embedtype`` tags. New handlers must be Python classes that inherit from either ``wagtail.richtext.LinkHandler`` or ``wagtail.richtext.EmbedHandler``. Your new classes should override at least some of the following methods (listed here for ``LinkHandler``, although ``EmbedHandler`` has an identical signature):
.. class:: LinkHandler
@ -116,7 +116,7 @@ Below is an example custom rewrite handler that implements these methods to add
.. code-block:: python
from django.contrib.auth import get_user_model
from wagtail.core.rich_text import LinkHandler
from wagtail.rich_text import LinkHandler
class UserLinkHandler(LinkHandler):
identifier = 'user'
@ -143,13 +143,13 @@ Rewrite handlers must also be registered with the feature registry via the :ref:
.. method:: FeatureRegistry.register_link_type(handler)
This method allows you to register a custom handler deriving from ``wagtail.core.rich_text.LinkHandler``, and adds it to the list of link handlers available during rich text conversion.
This method allows you to register a custom handler deriving from ``wagtail.rich_text.LinkHandler``, and adds it to the list of link handlers available during rich text conversion.
.. code-block:: python
# my_app/wagtail_hooks.py
from wagtail.core import hooks
from wagtail import hooks
from my_app.handlers import MyCustomLinkHandler
@hooks.register('register_rich_text_features')
@ -162,8 +162,8 @@ It is also possible to define link rewrite handlers for Wagtails built-in ``e
.. code-block:: python
from django.utils.html import escape
from wagtail.core import hooks
from wagtail.core.rich_text import LinkHandler
from wagtail import hooks
from wagtail.rich_text import LinkHandler
class NoFollowExternalLinkHandler(LinkHandler):
identifier = 'external'
@ -182,13 +182,13 @@ Similarly you can use ``email`` linktype to add a custom rewrite handler for ema
.. method:: FeatureRegistry.register_embed_type(handler)
This method allows you to register a custom handler deriving from ``wagtail.core.rich_text.EmbedHandler``, and adds it to the list of embed handlers available during rich text conversion.
This method allows you to register a custom handler deriving from ``wagtail.rich_text.EmbedHandler``, and adds it to the list of embed handlers available during rich text conversion.
.. code-block:: python
# my_app/wagtail_hooks.py
from wagtail.core import hooks
from wagtail import hooks
from my_app.handlers import MyCustomEmbedHandler
@hooks.register('register_rich_text_features')
@ -218,12 +218,12 @@ The ``default_features`` attribute of the feature registry is a list of feature
features.default_features.append('h1')
Outside of the ``register_rich_text_features`` hook - for example, inside a widget class - the feature registry can be imported as the object ``wagtail.core.rich_text.features``. A possible starting point for a rich text editor with feature support would be:
Outside of the ``register_rich_text_features`` hook - for example, inside a widget class - the feature registry can be imported as the object ``wagtail.rich_text.features``. A possible starting point for a rich text editor with feature support would be:
.. code-block:: python
from django.forms import widgets
from wagtail.core.rich_text import features
from wagtail.rich_text import features
class CustomRichTextArea(widgets.TextArea):
accepts_features = True

Wyświetl plik

@ -25,7 +25,7 @@ In your settings file, add the following apps to `INSTALLED_APPS`:
'wagtail.images',
'wagtail.search',
'wagtail.admin',
'wagtail.core',
'wagtail',
'modelcluster',
'taggit',
@ -66,7 +66,7 @@ Now make the following additions to your `urls.py` file:
from django.urls import path, include
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
urlpatterns = [

Wyświetl plik

@ -130,8 +130,8 @@ Edit `home/models.py` as follows, to add a `body` field to the model:
```python
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.models import Page
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
@ -222,8 +222,8 @@ Add the new `blog` app to `INSTALLED_APPS` in `mysite/settings/base.py`.
Lets start with a simple index page for our blog. In `blog/models.py`:
```python
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.models import Page
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
@ -276,8 +276,8 @@ Now we need a model and template for our blog posts. In `blog/models.py`:
```python
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import RichTextField
from wagtail.models import Page
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.search import index
@ -464,8 +464,8 @@ from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
from wagtail.models import Page, Orderable
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel
from wagtail.search import index
@ -619,8 +619,8 @@ from modelcluster.fields import ParentalKey
from modelcluster.contrib.taggit import ClusterTaggableManager
from taggit.models import TaggedItemBase
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
from wagtail.models import Page, Orderable
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, MultiFieldPanel
from wagtail.search import index

Wyświetl plik

@ -15,7 +15,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
@ -65,7 +65,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField, AbstractFormSubmission
@ -125,7 +125,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField, AbstractFormSubmission
@ -199,7 +199,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField, AbstractFormSubmission
@ -292,7 +292,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField
@ -434,7 +434,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField

Wyświetl plik

@ -30,7 +30,7 @@ from wagtail.admin.edit_handlers import (
FieldPanel, FieldRowPanel,
InlinePanel, MultiFieldPanel
)
from wagtail.core.fields import RichTextField
from wagtail.fields import RichTextField
from wagtail.contrib.forms.models import AbstractEmailForm, AbstractFormField

Wyświetl plik

@ -293,7 +293,7 @@ This signal handler would trigger the invalidation of the index page using the
from django.dispatch import receiver
from django.db.models.signals import pre_delete
from wagtail.core.signals import page_published
from wagtail.signals import page_published
from wagtail.contrib.frontend_cache.utils import PurgeBatch
...

Wyświetl plik

@ -5,13 +5,13 @@
Provides the legacy richtext wrapper.
Place `wagtail.contrib.legacy.richtext` before `wagtail.core` in `INSTALLED_APPS`.
Place `wagtail.contrib.legacy.richtext` before `wagtail` in `INSTALLED_APPS`.
```python
INSTALLED_APPS = [
...
"wagtail.contrib.legacy.richtext",
"wagtail.core",
"wagtail",
...
]
```

Wyświetl plik

@ -40,7 +40,7 @@ to allow a single author to be specified for each post.
from wagtail.admin.widgets import PageListingButton
from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtail.core import hooks
from wagtail import hooks
# Author & BlogPage model not shown in this example
from models import Author

Wyświetl plik

@ -50,7 +50,7 @@ Creating redirects for alternative page routes
If your project uses ``RoutablePageMixin`` to create pages with alternative routes, you might want to consider overriding the ``get_route_paths()`` method for those page types. Adding popular route paths to this list will result in the creation of additional redirects; helping visitors to alternative routes to get to the right place also.
For more information, please see :meth:`~wagtail.core.models.Page.get_route_paths`.
For more information, please see :meth:`~wagtail.models.Page.get_route_paths`.
Disabling automatic redirect creation
-------------------------------------
@ -59,8 +59,8 @@ Wagtail's default implementation works best for small-to-medium sized projects (
Overrides to the following ``Page`` methods are respected when generating redirects, but use of specific page fields in those overrides will trigger additional database queries.
* :meth:`~wagtail.core.models.Page.get_url_parts()`
* :meth:`~wagtail.core.models.Page.get_route_paths()`
* :meth:`~wagtail.models.Page.get_url_parts()`
* :meth:`~wagtail.models.Page.get_route_paths()`
If you find the feature is not a good fit for your project, you can disable it by adding the following to your project settings:

Wyświetl plik

@ -30,7 +30,7 @@ Add ``"wagtail.contrib.routable_page"`` to your INSTALLED_APPS:
The basics
==========
To use ``RoutablePageMixin``, you need to make your class inherit from both :class:`wagtail.contrib.routable_page.models.RoutablePageMixin` and :class:`wagtail.core.models.Page`, then define some view methods and decorate them with ``wagtail.contrib.routable_page.models.route``. These view methods behave like ordinary Django view functions, and must return an ``HttpResponse`` object; typically this is done through a call to ``django.shortcuts.render``.
To use ``RoutablePageMixin``, you need to make your class inherit from both :class:`wagtail.contrib.routable_page.models.RoutablePageMixin` and :class:`wagtail.models.Page`, then define some view methods and decorate them with ``wagtail.contrib.routable_page.models.route``. These view methods behave like ordinary Django view functions, and must return an ``HttpResponse`` object; typically this is done through a call to ``django.shortcuts.render``.
Here's an example of an ``EventIndexPage`` with three views, assuming that an ``EventPage`` model with an ``event_date`` field has been defined elsewhere:
@ -38,8 +38,8 @@ Here's an example of an ``EventIndexPage`` with three views, assuming that an ``
import datetime
from django.http import JsonResponse
from wagtail.core.fields import RichTextField
from wagtail.core.models import Page
from wagtail.fields import RichTextField
from wagtail.models import Page
from wagtail.contrib.routable_page.models import RoutablePageMixin, route
@ -141,7 +141,7 @@ Reversing URLs
>>> event_page.reverse_subpage('events_for_year', args=(2015, ))
'year/2015/'
This method only returns the part of the URL within the page. To get the full URL, you must append it to the values of either the :attr:`~wagtail.core.models.Page.url` or the :attr:`~wagtail.core.models.Page.full_url` attribute on your page:
This method only returns the part of the URL within the page. To get the full URL, you must append it to the values of either the :attr:`~wagtail.models.Page.url` or the :attr:`~wagtail.models.Page.full_url` attribute on your page:
.. code-block:: python
@ -158,7 +158,7 @@ The route name defaults to the name of the view. You can override this name with
.. code-block:: python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail.contrib.routable_page.models import RoutablePageMixin, route

Wyświetl plik

@ -24,7 +24,7 @@ Usage
```python
from wagtail.contrib.typed_table_block.blocks import TypedTableBlock
from wagtail.core import blocks
from wagtail import blocks
from wagtail.images.blocks import ImageChooserBlock
class DemoStreamBlock(blocks.StreamBlock):

Wyświetl plik

@ -14,7 +14,7 @@ Registering functions with a Wagtail hook is done through the ``@hooks.register`
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('name_of_hook')
def my_hook_function(arg1, arg2...)
@ -120,7 +120,7 @@ Hooks for building new areas of the admin interface (alongside pages, images, do
from django.utils.safestring import mark_safe
from wagtail.admin.ui.components import Component
from wagtail.core import hooks
from wagtail import hooks
class WelcomePanel(Component):
order = 50
@ -166,7 +166,7 @@ Hooks for building new areas of the admin interface (alongside pages, images, do
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('construct_main_menu')
def hide_explorer_menu_item_from_frank(request, menu_items):
@ -201,7 +201,7 @@ This hook can be added to a sub-class of ``BaseSettingsPanel``. For example:
.. code-block:: python
from wagtail.admin.views.account import BaseSettingsPanel
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_account_settings_panel')
class CustomSettingsPanel(BaseSettingsPanel):
@ -215,7 +215,7 @@ Alternatively, it can also be added to a function. For example, this function is
.. code-block:: python
from wagtail.admin.views.account import BaseSettingsPanel
from wagtail.core import hooks
from wagtail import hooks
class CustomSettingsPanel(BaseSettingsPanel):
name = 'custom'
@ -242,7 +242,7 @@ More details about the options that are available can be found at :doc:`/extendi
.. code-block:: python
from django.urls import reverse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_account_menu_item')
def register_account_delete_account(request):
@ -274,7 +274,7 @@ More details about the options that are available can be found at :doc:`/extendi
from django.urls import reverse
from wagtail.core import hooks
from wagtail import hooks
from wagtail.admin.menu import MenuItem
@hooks.register('register_admin_menu_item')
@ -294,7 +294,7 @@ More details about the options that are available can be found at :doc:`/extendi
from django.http import HttpResponse
from django.urls import path
from wagtail.core import hooks
from wagtail import hooks
def admin_view(request):
return HttpResponse(
@ -373,7 +373,7 @@ More details about the options that are available can be found at :doc:`/extendi
.. code-block:: python
from django.urls import reverse
from wagtail.core import hooks
from wagtail import hooks
from wagtail.admin.search import SearchArea
@hooks.register('register_admin_search_area')
@ -391,7 +391,7 @@ More details about the options that are available can be found at :doc:`/extendi
.. code-block:: python
from django.contrib.auth.models import Permission
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_permissions')
@ -421,7 +421,7 @@ More details about the options that are available can be found at :doc:`/extendi
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('filter_form_submissions_for_user')
@ -458,7 +458,7 @@ Hooks for customising the editing interface for pages and snippets.
from django.templatetags.static import static
from django.utils.html import format_html
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('insert_editor_css')
def editor_css():
@ -480,7 +480,7 @@ Hooks for customising the editing interface for pages and snippets.
from django.utils.html import format_html
from django.templatetags.static import static
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('insert_global_admin_css')
def global_admin_css():
@ -500,7 +500,7 @@ Hooks for customising the editing interface for pages and snippets.
from django.utils.safestring import mark_safe
from django.templatetags.static import static
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('insert_editor_js')
def editor_js():
@ -538,7 +538,7 @@ Hooks for customising the editing interface for pages and snippets.
from django.utils.safestring import mark_safe
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('insert_global_admin_js')
def global_admin_js():
@ -594,7 +594,7 @@ Hooks for customising the way users are directed through the process of creating
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('after_create_page')
def do_after_page_create(request, page):
@ -628,7 +628,7 @@ Hooks for customising the way users are directed through the process of creating
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
from .models import AwesomePage
from .admin_views import edit_awesome_page
@ -662,7 +662,7 @@ Hooks for customising the way users are directed through the process of creating
from django.utils.html import format_html
from wagtail.admin import messages
from wagtail.core import hooks
from wagtail import hooks
from .models import AwesomePage
@ -817,7 +817,7 @@ Hooks for customising the way users are directed through the process of creating
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
from wagtail.admin.action_menu import ActionMenuItem
class GuacamoleMenuItem(ActionMenuItem):
@ -889,7 +889,7 @@ Hooks for customising the way users are directed through the process of creating
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
class UserbarPuppyLinkItem:
def render(self, request):
@ -917,7 +917,7 @@ Hooks for customising the way admins are directed through the process of editing
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('after_create_user')
def do_after_page_create(request, user):
@ -941,7 +941,7 @@ Hooks for customising the way admins are directed through the process of editing
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
from .models import AwesomePage
from .admin_views import edit_awesome_page
@ -999,7 +999,7 @@ Choosers
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('construct_page_chooser_queryset')
def show_my_pages_only(pages, request):
@ -1018,7 +1018,7 @@ Choosers
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('construct_document_chooser_queryset')
def show_my_uploaded_documents_only(documents, request):
@ -1037,7 +1037,7 @@ Choosers
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('construct_image_chooser_queryset')
def show_my_uploaded_images_only(images, request):
@ -1059,7 +1059,7 @@ Page explorer
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('construct_explorer_page_queryset')
def show_my_profile_only(parent_page, pages, request):
@ -1186,7 +1186,7 @@ Page serving
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('before_serve_page')
def block_googlebot(page, request, serve_args, serve_kwargs):
@ -1221,7 +1221,7 @@ Hooks for working with registered Snippets.
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('after_edit_snippet')
def after_snippet_update(request, instance):
@ -1238,7 +1238,7 @@ Hooks for working with registered Snippets.
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('before_edit_snippet')
def block_snippet_edit(request, instance):
@ -1272,7 +1272,7 @@ Hooks for working with registered Snippets.
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('after_delete_snippet')
def after_snippet_delete(request, instances):
@ -1291,7 +1291,7 @@ Hooks for working with registered Snippets.
from django.http import HttpResponse
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('before_delete_snippet')
def before_snippet_delete(request, instances):
@ -1330,7 +1330,7 @@ Hooks for working with registered Snippets.
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
from wagtail.snippets.action_menu import ActionMenuItem
class GuacamoleMenuItem(ActionMenuItem):
@ -1443,7 +1443,7 @@ Hooks for registering and customising bulk actions. See :ref:`here <custom_bulk_
.. code-block:: python
from wagtail.admin.views.bulk_action import BulkAction
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("register_bulk_action")
@ -1473,7 +1473,7 @@ Hooks for registering and customising bulk actions. See :ref:`here <custom_bulk_
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("before_bulk_action")
def hook_func(request, action_type, objects, action_class_instance):
@ -1492,7 +1492,7 @@ Hooks for registering and customising bulk actions. See :ref:`here <custom_bulk_
.. code-block:: python
from wagtail.core import hooks
from wagtail import hooks
@hooks.register("after_bulk_action")
def hook_func(request, action_type, objects, action_class_instance):
@ -1517,21 +1517,21 @@ Audit log
from django.utils.translation import gettext_lazy as _
from wagtail.core import hooks
from wagtail import hooks
@hooks.register('register_log_actions')
def additional_log_actions(actions):
actions.register_action('wagtail_package.echo', _('Echo'), _('Sent an echo'))
Alternatively, for a log message that varies according to the log entry's data, create a subclass of ``wagtail.core.log_actions.LogFormatter`` that overrides the ``format_message`` method, and use ``register_action`` as a decorator on that class:
Alternatively, for a log message that varies according to the log entry's data, create a subclass of ``wagtail.log_actions.LogFormatter`` that overrides the ``format_message`` method, and use ``register_action`` as a decorator on that class:
.. code-block:: python
from django.utils.translation import gettext_lazy as _
from wagtail.core import hooks
from wagtail.core.log_actions import LogFormatter
from wagtail import hooks
from wagtail.log_actions import LogFormatter
@hooks.register('register_log_actions')
def additional_log_actions(actions):

Wyświetl plik

@ -23,7 +23,7 @@ Django needs to be configured to support Jinja2 templates. As the Wagtail admin
'APP_DIRS': True,
'OPTIONS': {
'extensions': [
'wagtail.core.jinja2tags.core',
'wagtail.jinja2tags.core',
'wagtail.admin.jinja2tags.userbar',
'wagtail.images.jinja2tags.images',
],

Wyświetl plik

@ -1,7 +1,7 @@
Pages
=====
Wagtail requires a little careful setup to define the types of content that you want to present through your website. The basic unit of content in Wagtail is the :class:`~wagtail.core.models.Page`, and all of your page-level content will inherit basic webpage-related properties from it. But for the most part, you will be defining content yourself, through the construction of Django models using Wagtail's ``Page`` as a base.
Wagtail requires a little careful setup to define the types of content that you want to present through your website. The basic unit of content in Wagtail is the :class:`~wagtail.models.Page`, and all of your page-level content will inherit basic webpage-related properties from it. But for the most part, you will be defining content yourself, through the construction of Django models using Wagtail's ``Page`` as a base.
Wagtail organizes content created from your models in a tree, which can have any structure and combination of model objects in it. Wagtail doesn't prescribe ways to organize and interrelate your content, but here we've sketched out some strategies for organizing your models.

Wyświetl plik

@ -4,10 +4,10 @@
Recipes
=======
Overriding the :meth:`~wagtail.core.models.Page.serve` Method
Overriding the :meth:`~wagtail.models.Page.serve` Method
--------------------------------------------------------------------
Wagtail defaults to serving :class:`~wagtail.core.models.Page`-derived models by passing a reference to the page object to a Django HTML template matching the model's name, but suppose you wanted to serve something other than HTML? You can override the :meth:`~wagtail.core.models.Page.serve` method provided by the :class:`~wagtail.core.models.Page` class and handle the Django request and response more directly.
Wagtail defaults to serving :class:`~wagtail.models.Page`-derived models by passing a reference to the page object to a Django HTML template matching the model's name, but suppose you wanted to serve something other than HTML? You can override the :meth:`~wagtail.models.Page.serve` method provided by the :class:`~wagtail.models.Page` class and handle the Django request and response more directly.
Consider this example from the Wagtail demo site's ``models.py``, which serves an ``EventPage`` object as an iCal file if the ``format`` variable is set in the request:
@ -34,14 +34,14 @@ Consider this example from the Wagtail demo site's ``models.py``, which serves a
# Display event page as usual
return super().serve(request)
:meth:`~wagtail.core.models.Page.serve` takes a Django request object and returns a Django response object. Wagtail returns a ``TemplateResponse`` object with the template and context which it generates, which allows middleware to function as intended, so keep in mind that a simpler response object like a ``HttpResponse`` will not receive these benefits.
:meth:`~wagtail.models.Page.serve` takes a Django request object and returns a Django response object. Wagtail returns a ``TemplateResponse`` object with the template and context which it generates, which allows middleware to function as intended, so keep in mind that a simpler response object like a ``HttpResponse`` will not receive these benefits.
With this strategy, you could use Django or Python utilities to render your model in JSON or XML or any other format you'd like.
.. _overriding_route_method:
Adding Endpoints with Custom :meth:`~wagtail.core.models.Page.route` Methods
Adding Endpoints with Custom :meth:`~wagtail.models.Page.route` Methods
-----------------------------------------------------------------------------------
.. note::
@ -80,20 +80,20 @@ Wagtail routes requests by iterating over the path components (separated with a
# the page matches the request, but isn't published, so 404
raise Http404
:meth:`~wagtail.core.models.Page.route` takes the current object (``self``), the ``request`` object, and a list of the remaining ``path_components`` from the request URL. It either continues delegating routing by calling :meth:`~wagtail.core.models.Page.route` again on one of its children in the Wagtail tree, or ends the routing process by returning a ``RouteResult`` object or raising a 404 error.
:meth:`~wagtail.models.Page.route` takes the current object (``self``), the ``request`` object, and a list of the remaining ``path_components`` from the request URL. It either continues delegating routing by calling :meth:`~wagtail.models.Page.route` again on one of its children in the Wagtail tree, or ends the routing process by returning a ``RouteResult`` object or raising a 404 error.
The ``RouteResult`` object (defined in wagtail.core.url_routing) encapsulates all the information Wagtail needs to call a page's :meth:`~wagtail.core.models.Page.serve` method and return a final response: this information consists of the page object, and any additional ``args``/``kwargs`` to be passed to :meth:`~wagtail.core.models.Page.serve`.
The ``RouteResult`` object (defined in wagtail.url_routing) encapsulates all the information Wagtail needs to call a page's :meth:`~wagtail.models.Page.serve` method and return a final response: this information consists of the page object, and any additional ``args``/``kwargs`` to be passed to :meth:`~wagtail.models.Page.serve`.
By overriding the :meth:`~wagtail.core.models.Page.route` method, we could create custom endpoints for each object in the Wagtail tree. One use case might be using an alternate template when encountering the ``print/`` endpoint in the path. Another might be a REST API which interacts with the current object. Just to see what's involved, lets make a simple model which prints out all of its child path components.
By overriding the :meth:`~wagtail.models.Page.route` method, we could create custom endpoints for each object in the Wagtail tree. One use case might be using an alternate template when encountering the ``print/`` endpoint in the path. Another might be a REST API which interacts with the current object. Just to see what's involved, lets make a simple model which prints out all of its child path components.
First, ``models.py``:
.. code-block:: python
from django.shortcuts import render
from wagtail.core.url_routing import RouteResult
from wagtail.url_routing import RouteResult
from django.http.response import Http404
from wagtail.core.models import Page
from wagtail.models import Page
...

Wyświetl plik

@ -2,7 +2,7 @@
Model Reference
===============
.. automodule:: wagtail.core.models
.. automodule:: wagtail.models
This document contains reference information for the model classes inside the ``wagtailcore`` module.
@ -94,7 +94,7 @@ Database fields
Wagtail does not include any menu implementation by default, which means that this field will not do anything in the front facing content unless built that way in a specific Wagtail installation.
However, this is used by the :meth:`~wagtail.core.query.PageQuerySet.in_menu` QuerySet filter to make it easier to query for pages that use this field.
However, this is used by the :meth:`~wagtail.query.PageQuerySet.in_menu` QuerySet filter to make it easier to query for pages that use this field.
Defaults to ``False`` and can be overridden on the model with ``show_in_menus_default = True``.
@ -335,7 +335,7 @@ In addition to the model fields provided, ``Page`` has many properties and metho
The ``Site`` model is useful for multi-site installations as it allows an administrator to configure which part of the tree to use for each hostname that the server responds on.
The :meth:`~wagtail.core.models.Site.find_for_request` function returns the Site object that will handle the given HTTP request.
The :meth:`~wagtail.models.Site.find_for_request` function returns the Site object that will handle the given HTTP request.
Database fields
@ -371,7 +371,7 @@ Database fields
.. attribute:: root_page
(foreign key to :class:`~wagtail.core.models.Page`)
(foreign key to :class:`~wagtail.models.Page`)
This is a link to the root page of the site. This page will be what appears at the ``/`` URL on the site and would usually be a homepage.
@ -458,7 +458,7 @@ The ``locale`` and ``translation_key`` fields have a unique key constraint to pr
.. attribute:: locale
(Foreign Key to :class:`~wagtail.core.models.Locale`)
(Foreign Key to :class:`~wagtail.models.Locale`)
For pages, this defaults to the locale of the parent page.
@ -491,9 +491,9 @@ The ``locale`` and ``translation_key`` fields have a unique key constraint to pr
Every time a page is edited a new ``PageRevision`` is created and saved to the database. It can be used to find the full history of all changes that have been made to a page and it also provides a place for new changes to be kept before going live.
- Revisions can be created from any :class:`~wagtail.core.models.Page` object by calling its :meth:`~Page.save_revision` method
- Revisions can be created from any :class:`~wagtail.models.Page` object by calling its :meth:`~Page.save_revision` method
- The content of the page is JSON-serialisable and stored in the :attr:`~PageRevision.content` field
- You can retrieve a ``PageRevision`` as a :class:`~wagtail.core.models.Page` object by calling the :meth:`~PageRevision.as_page_object` method
- You can retrieve a ``PageRevision`` as a :class:`~wagtail.models.Page` object by calling the :meth:`~PageRevision.as_page_object` method
Database fields
~~~~~~~~~~~~~~~
@ -502,7 +502,7 @@ Database fields
.. attribute:: page
(foreign key to :class:`~wagtail.core.models.Page`)
(foreign key to :class:`~wagtail.models.Page`)
.. attribute:: submitted_for_moderation
@ -567,7 +567,7 @@ Methods and properties
.. automethod:: as_page_object
This method retrieves this revision as an instance of its :class:`~wagtail.core.models.Page` subclass.
This method retrieves this revision as an instance of its :class:`~wagtail.models.Page` subclass.
.. automethod:: approve_moderation
@ -599,7 +599,7 @@ Database fields
.. attribute:: page
(foreign key to :class:`~wagtail.core.models.Page`)
(foreign key to :class:`~wagtail.models.Page`)
.. attribute:: permission_type
@ -615,7 +615,7 @@ Database fields
.. attribute:: page
(foreign key to :class:`~wagtail.core.models.Page`)
(foreign key to :class:`~wagtail.models.Page`)
.. attribute:: password

Wyświetl plik

@ -137,11 +137,11 @@ PageChooserPanel
.. class:: PageChooserPanel(field_name, page_type=None, can_choose_root=False)
You can explicitly link :class:`~wagtail.core.models.Page`-derived models together using the :class:`~wagtail.core.models.Page` model and ``PageChooserPanel``.
You can explicitly link :class:`~wagtail.models.Page`-derived models together using the :class:`~wagtail.models.Page` model and ``PageChooserPanel``.
.. code-block:: python
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail.admin.edit_handlers import PageChooserPanel
@ -333,11 +333,11 @@ Inline Panels and Model Clusters
The ``django-modelcluster`` module allows for streamlined relation of extra models to a Wagtail page via a ForeignKey-like relationship called ``ParentalKey``. Normally, your related objects "cluster" would need to be created beforehand (or asynchronously) before being linked to a Page; however, objects related to a Wagtail page via ``ParentalKey`` can be created on-the-fly and saved to a draft revision of a ``Page`` object.
Let's look at the example of adding related links to a :class:`~wagtail.core.models.Page`-derived model. We want to be able to add as many as we like, assign an order, and do all of this without leaving the page editing screen.
Let's look at the example of adding related links to a :class:`~wagtail.models.Page`-derived model. We want to be able to add as many as we like, assign an order, and do all of this without leaving the page editing screen.
.. code-block:: python
from wagtail.core.models import Orderable, Page
from wagtail.models import Orderable, Page
from modelcluster.fields import ParentalKey
# The abstract model for related links, complete with panels

Wyświetl plik

@ -2,7 +2,7 @@
Page QuerySet reference
=======================
All models that inherit from :class:`~wagtail.core.models.Page` are given some extra QuerySet methods accessible from their ``.objects`` attribute.
All models that inherit from :class:`~wagtail.models.Page` are given some extra QuerySet methods accessible from their ``.objects`` attribute.
Examples
@ -31,7 +31,7 @@ Examples
Reference
=========
.. automodule:: wagtail.core.query
.. automodule:: wagtail.query
.. autoclass:: PageQuerySet
.. automethod:: live
@ -268,7 +268,7 @@ Reference
# in a minimum number of database queries.
homepage.get_children().specific()
See also: :py:attr:`Page.specific <wagtail.core.models.Page.specific>`
See also: :py:attr:`Page.specific <wagtail.models.Page.specific>`
.. automethod:: defer_streamfields

Wyświetl plik

@ -924,9 +924,9 @@ set ``WAGTAIL_WORKFLOW_REQUIRE_REAPPROVAL_ON_EDIT = False``.
.. code-block:: python
WAGTAIL_FINISH_WORKFLOW_ACTION = 'wagtail.core.workflows.publish_workflow_state'
WAGTAIL_FINISH_WORKFLOW_ACTION = 'wagtail.workflows.publish_workflow_state'
This sets the function to be called when a workflow completes successfully - by default, ``wagtail.core.workflows.publish_workflow_state``,
This sets the function to be called when a workflow completes successfully - by default, ``wagtail.workflows.publish_workflow_state``,
which publishes the page. The function must accept a ``WorkflowState`` object as its only positional argument.
``WAGTAIL_WORKFLOW_CANCEL_ON_PUBLISH``

Wyświetl plik

@ -25,7 +25,7 @@ example showing how you might notify your team when something is published:
.. code-block:: python
from wagtail.core.signals import page_published
from wagtail.signals import page_published
import requests
@ -55,7 +55,7 @@ wish to do something when a new blog post is published:
.. code-block:: python
from wagtail.core.signals import page_published
from wagtail.signals import page_published
from mysite.models import BlogPostPage
# Do something clever for each model type
@ -66,7 +66,7 @@ wish to do something when a new blog post is published:
# Register listeners for each page model class
page_published.connect(receiver, sender=BlogPostPage)
Wagtail provides access to a list of registered page types through the ``get_page_models()`` function in ``wagtail.core.models``.
Wagtail provides access to a list of registered page types through the ``get_page_models()`` function in ``wagtail.models``.
Read the :ref:`Django documentation <connecting-to-specific-signals>` for more information about specifying senders.
@ -110,7 +110,7 @@ The best way to distinguish between a 'move' and 'reorder' is to compare the ``u
.. code-block:: python
from wagtail.core.signals import pre_page_move
from wagtail.signals import pre_page_move
from wagtail.contrib.frontend_cache.utils import purge_page_from_cache
# Clear a page's old URLs from the cache when it moves to a different section

Wyświetl plik

@ -6,7 +6,7 @@ StreamField block reference
This document details the block types provided by Wagtail for use in :ref:`StreamField <streamfield>`, and how they can be combined into new block types.
.. class:: wagtail.core.fields.StreamField(blocks, blank=False, min_num=None, max_num=None, block_counts=None)
.. class:: wagtail.fields.StreamField(blocks, blank=False, min_num=None, max_num=None, block_counts=None)
A model field for representing long-form content as a sequence of content blocks of various types. See :ref:`streamfield`.
@ -53,7 +53,7 @@ All block definitions accept the following optional keyword arguments:
Field block types
-----------------
.. class:: wagtail.core.blocks.CharBlock
.. class:: wagtail.blocks.CharBlock
A single-line text input. The following keyword arguments are accepted in addition to the standard ones:
@ -65,7 +65,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.TextBlock
.. class:: wagtail.blocks.TextBlock
A multi-line text input. As with ``CharBlock``, the following keyword arguments are accepted in addition to the standard ones:
@ -78,7 +78,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.EmailBlock
.. class:: wagtail.blocks.EmailBlock
A single-line email input that validates that the value is a valid e-mail address. The following keyword arguments are accepted in addition to the standard ones:
@ -88,7 +88,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.IntegerBlock
.. class:: wagtail.blocks.IntegerBlock
A single-line integer input that validates that the value is a valid whole number. The following keyword arguments are accepted in addition to the standard ones:
@ -100,7 +100,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.FloatBlock
.. class:: wagtail.blocks.FloatBlock
A single-line Float input that validates that the value is a valid floating point number. The following keyword arguments are accepted in addition to the standard ones:
@ -111,7 +111,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.DecimalBlock
.. class:: wagtail.blocks.DecimalBlock
A single-line decimal input that validates that the value is a valid decimal number. The following keyword arguments are accepted in addition to the standard ones:
@ -125,7 +125,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.RegexBlock
.. class:: wagtail.blocks.RegexBlock
A single-line text input that validates a string against a regular expression. The regular expression used for validation must be supplied as the first argument, or as the keyword argument ``regex``.
@ -147,7 +147,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.URLBlock
.. class:: wagtail.blocks.URLBlock
A single-line text input that validates that the string is a valid URL. The following keyword arguments are accepted in addition to the standard ones:
@ -159,7 +159,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.BooleanBlock
.. class:: wagtail.blocks.BooleanBlock
A checkbox. The following keyword arguments are accepted in addition to the standard ones:
@ -168,7 +168,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.DateBlock
.. class:: wagtail.blocks.DateBlock
A date picker. The following keyword arguments are accepted in addition to the standard ones:
@ -179,7 +179,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.TimeBlock
.. class:: wagtail.blocks.TimeBlock
A time picker. The following keyword arguments are accepted in addition to the standard ones:
@ -189,7 +189,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.DateTimeBlock
.. class:: wagtail.blocks.DateTimeBlock
A combined date / time picker. The following keyword arguments are accepted in addition to the standard ones:
@ -200,7 +200,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.RichTextBlock
.. class:: wagtail.blocks.RichTextBlock
A WYSIWYG editor for creating formatted text including links, bold / italics etc. The following keyword arguments are accepted in addition to the standard ones:
@ -212,7 +212,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.RawHTMLBlock
.. class:: wagtail.blocks.RawHTMLBlock
A text area for entering raw HTML which will be rendered unescaped in the page output. The following keyword arguments are accepted in addition to the standard ones:
@ -227,7 +227,7 @@ Field block types
When this block is in use, there is nothing to prevent editors from inserting malicious scripts into the page, including scripts that would allow the editor to acquire administrator privileges when another administrator views the page. Do not use this block unless your editors are fully trusted.
.. class:: wagtail.core.blocks.BlockQuoteBlock
.. class:: wagtail.blocks.BlockQuoteBlock
A text field, the contents of which will be wrapped in an HTML `<blockquote>` tag pair in the page output. The following keyword arguments are accepted in addition to the standard ones:
@ -239,7 +239,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.ChoiceBlock
.. class:: wagtail.blocks.ChoiceBlock
A dropdown select box for choosing one item from a list of choices. The following keyword arguments are accepted in addition to the standard ones:
@ -279,7 +279,7 @@ Field block types
.. _streamfield_multiplechoiceblock:
.. class:: wagtail.core.blocks.MultipleChoiceBlock
.. class:: wagtail.blocks.MultipleChoiceBlock
A select box for choosing multiple items from a list of choices. The following keyword arguments are accepted in addition to the standard ones:
@ -291,7 +291,7 @@ Field block types
:param form_classname: A value to add to the form field's ``class`` attribute when rendered on the page editing form.
.. class:: wagtail.core.blocks.PageChooserBlock
.. class:: wagtail.blocks.PageChooserBlock
A control for selecting a page object, using Wagtail's page browser. The following keyword arguments are accepted in addition to the standard ones:
@ -338,7 +338,7 @@ Structural block types
.. _streamfield_staticblock:
.. class:: wagtail.core.blocks.StaticBlock
.. class:: wagtail.blocks.StaticBlock
A block which doesn't have any fields, thus passes no particular values to its template during rendering. This can be useful if you need the editor to be able to insert some content which is always the same or doesn't need to be configured within the page editor, such as an address, embed code from third-party services, or more complex pieces of code if the template uses template tags. The following additional keyword argument is accepted:
@ -363,7 +363,7 @@ Structural block types
template = 'latest_posts.html'
.. class:: wagtail.core.blocks.StructBlock
.. class:: wagtail.blocks.StructBlock
A block consisting of a fixed group of sub-blocks to be displayed together. Takes a list of ``(name, block_definition)`` tuples as its first argument:
@ -411,12 +411,12 @@ Structural block types
:param form_classname: An HTML ``class`` attribute to set on the root element of this block as displayed in the editing interface. Defaults to ``struct-block``; note that the admin interface has CSS styles defined on this class, so it is advised to include ``struct-block`` in this value when overriding. See :ref:`custom_editing_interfaces_for_structblock`.
:param form_template: Path to a Django template to use to render this block's form. See :ref:`custom_editing_interfaces_for_structblock`.
:param value_class: A subclass of ``wagtail.core.blocks.StructValue`` to use as the type of returned values for this block. See :ref:`custom_value_class_for_structblock`.
:param value_class: A subclass of ``wagtail.blocks.StructValue`` to use as the type of returned values for this block. See :ref:`custom_value_class_for_structblock`.
:param label_format:
Determines the label shown when the block is collapsed in the editing interface. By default, the value of the first sub-block in the StructBlock is shown, but this can be customised by setting a string here with block names contained in braces - e.g. ``label_format = "Profile for {first_name} {surname}"``
.. class:: wagtail.core.blocks.ListBlock
.. class:: wagtail.blocks.ListBlock
A block consisting of many sub-blocks, all of the same type. The editor can add an unlimited number of sub-blocks, and re-order and delete them. Takes the definition of the sub-block as its first argument:
@ -448,7 +448,7 @@ Structural block types
:param collapsed: When true, all sub-blocks are initially collapsed.
.. class:: wagtail.core.blocks.StreamBlock
.. class:: wagtail.blocks.StreamBlock
A block consisting of a sequence of sub-blocks of different types, which can be mixed and reordered at will. Used as the overall mechanism of the StreamField itself, but can also be nested or used within other structural block types. Takes a list of ``(name, block_definition)`` tuples as its first argument:

Wyświetl plik

@ -5,12 +5,12 @@ Form widget client-side API
In order for the StreamField editing interface to dynamically create form fields, any Django form widgets used within StreamField blocks must have an accompanying JavaScript implementation, defining how the widget is rendered client-side and populated with data, and how to extract data from that field. Wagtail provides this implementation for widgets inheriting from ``django.forms.widgets.Input``, ``django.forms.Textarea``, ``django.forms.Select`` and ``django.forms.RadioSelect``. For any other widget types, or ones which require custom client-side behaviour, you will need to provide your own implementation.
The `telepath <https://wagtail.github.io/telepath/>`__ library is used to set up mappings between Python widget classes and their corresponding JavaScript implementations. To create a mapping, define a subclass of ``wagtail.core.widget_adapters.WidgetAdapter`` and register it with ``wagtail.core.telepath.register``.
The `telepath <https://wagtail.github.io/telepath/>`__ library is used to set up mappings between Python widget classes and their corresponding JavaScript implementations. To create a mapping, define a subclass of ``wagtail.widget_adapters.WidgetAdapter`` and register it with ``wagtail.telepath.register``.
.. code-block:: python
from wagtail.core.telepath import register
from wagtail.core.widget_adapters import WidgetAdapter
from wagtail.telepath import register
from wagtail.widget_adapters import WidgetAdapter
class FancyInputAdapter(WidgetAdapter):
# Identifier matching the one registered on the client side

Wyświetl plik

@ -233,7 +233,7 @@ Wagtail now provides a set of helper functions for constructing form data: see :
.. code-block:: python
from wagtail.test.utils.form_data import rich_text
from wagtail.tests.utils.form_data import rich_text
self.assertCanCreate(root_page, ContentPage, {
'title': 'About us',

Wyświetl plik

@ -1,8 +1,8 @@
# Page models
Each page type (a.k.a. content type) in Wagtail is represented by a Django model. All page models must inherit from the {class}`wagtail.core.models.Page` class.
Each page type (a.k.a. content type) in Wagtail is represented by a Django model. All page models must inherit from the {class}`wagtail.models.Page` class.
As all page types are Django models, you can use any field type that Django provides. See [Model field reference](https://docs.djangoproject.com/en/stable/ref/models/fields/) for a complete list of field types you can use. Wagtail also provides `wagtail.core.fields.RichTextField` which provides a WYSIWYG editor for editing rich-text content.
As all page types are Django models, you can use any field type that Django provides. See [Model field reference](https://docs.djangoproject.com/en/stable/ref/models/fields/) for a complete list of field types you can use. Wagtail also provides `wagtail.fields.RichTextField` which provides a WYSIWYG editor for editing rich-text content.
```{note}
If you're not yet familiar with Django models, have a quick look at the following links to get you started:
@ -20,8 +20,8 @@ from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.core.models import Page, Orderable
from wagtail.core.fields import RichTextField
from wagtail.models import Page, Orderable
from wagtail.fields import RichTextField
from wagtail.admin.edit_handlers import FieldPanel, MultiFieldPanel, InlinePanel
from wagtail.search import index
@ -189,7 +189,7 @@ super().get_url_parts(*args, **kwargs)
While you could pass only the `request` keyword argument, passing all arguments as-is ensures compatibility with any
future changes to these method signatures.
For more information, please see {meth}`wagtail.core.models.Page.get_url_parts`.
For more information, please see {meth}`wagtail.models.Page.get_url_parts`.
#### Obtaining URLs for page instances
@ -198,11 +198,11 @@ The `Page.get_url(request)` method can be called whenever a page URL is needed.
A common use case for `get_url(request)` is in any custom template tag your project may include for generating navigation menus. When writing such a custom template tag, ensure that it includes `takes_context=True` and use `context.get('request')` to safely pass the
request or `None` if no request exists in the context.
For more information, please see {meth}`wagtail.core.models.Page.get_url`.
For more information, please see {meth}`wagtail.models.Page.get_url`.
In the event a full URL (including the protocol and domain) is needed, `Page.get_full_url(request)` can be used instead. Whenever possible, the optional `request` argument should be included to enable per-request caching of site-level URL information.
For more information, please see {meth}`wagtail.core.models.Page.get_full_url`.
For more information, please see {meth}`wagtail.models.Page.get_full_url`.
## Template rendering
@ -324,7 +324,7 @@ Wagtail can nest the content of other models within the page. This is useful for
Each inline model requires the following:
- It must inherit from {class}`wagtail.core.models.Orderable`
- It must inherit from {class}`wagtail.models.Orderable`
- It must have a `ParentalKey` to the parent model
```{note} django-modelcluster and ParentalKey
@ -342,7 +342,7 @@ For example, the following inline model can be used to add related links (a list
```python
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.core.models import Orderable
from wagtail.models import Orderable
class BlogPageRelatedLink(Orderable):
@ -372,7 +372,7 @@ The first argument must match the value of the `related_name` attribute of the `
Wagtail uses Django's [multi-table inheritance](https://docs.djangoproject.com/en/3.1/topics/db/models/#multi-table-inheritance) feature to allow multiple page models to be used in the same tree.
Each page is added to both Wagtail's builtin {class}`~wagtail.core.models.Page` model as well as its user-defined model (such as the `BlogPage` model created earlier).
Each page is added to both Wagtail's builtin {class}`~wagtail.models.Page` model as well as its user-defined model (such as the `BlogPage` model created earlier).
Pages can exist in Python code in two forms, an instance of `Page` or an instance of the page model.
@ -380,7 +380,7 @@ When working with multiple page types together, you will typically use instances
```python
# Get all pages in the database
>>> from wagtail.core.models import Page
>>> from wagtail.models import Page
>>> Page.objects.all()
[<Page: Homepage>, <Page: About us>, <Page: Blog>, <Page: A Blog post>, <Page: Another Blog post>]
```
@ -444,11 +444,11 @@ news_items = NewsItemPage.objects.live().order_by('-publication_date')
(custom_page_managers)=
### Custom Page managers
You can add a custom `Manager` to your `Page` class. Any custom Managers should inherit from `wagtail.core.models.PageManager`:
You can add a custom `Manager` to your `Page` class. Any custom Managers should inherit from `wagtail.models.PageManager`:
```python
from django.db import models
from wagtail.core.models import Page, PageManager
from wagtail.models import Page, PageManager
class EventPageManager(PageManager):
""" Custom manager for Event pages """
@ -459,12 +459,12 @@ class EventPage(Page):
objects = EventPageManager()
```
Alternately, if you only need to add extra `QuerySet` methods, you can inherit from `wagtail.core.models.PageQuerySet` to build a custom `Manager`:
Alternately, if you only need to add extra `QuerySet` methods, you can inherit from `wagtail.models.PageQuerySet` to build a custom `Manager`:
```python
from django.db import models
from django.utils import timezone
from wagtail.core.models import Page, PageManager, PageQuerySet
from wagtail.models import Page, PageManager, PageQuerySet
class EventPageQuerySet(PageQuerySet):
def future(self):

Wyświetl plik

@ -23,7 +23,7 @@ Wagtail provides a shortcut for searching pages: the ``.search()`` ``QuerySet``
.. code-block:: python
# Search future EventPages
>>> from wagtail.core.models import EventPage
>>> from wagtail.models import EventPage
>>> EventPage.objects.filter(date__gt=timezone.now()).search("Hello world!")
@ -382,7 +382,7 @@ Here's an example Django view that could be used to add a "search" page to your
from django.shortcuts import render
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail.search.models import Query

Wyświetl plik

@ -126,7 +126,7 @@ To attach multiple adverts to a page, the ``FieldPanel`` can be placed on an inl
from django.db import models
from wagtail.core.models import Page, Orderable
from wagtail.models import Page, Orderable
from modelcluster.fields import ParentalKey

Wyświetl plik

@ -19,9 +19,9 @@ Using StreamField
from django.db import models
from wagtail.core.models import Page
from wagtail.core.fields import StreamField
from wagtail.core import blocks
from wagtail.models import Page
from wagtail.fields import StreamField
from wagtail import blocks
from wagtail.admin.edit_handlers import FieldPanel, StreamFieldPanel
from wagtail.images.blocks import ImageChooserBlock
@ -551,7 +551,7 @@ If you change an existing RichTextField to a StreamField, the database migration
# -*- coding: utf-8 -*-
from django.db import models, migrations
from wagtail.core.rich_text import RichText
from wagtail.rich_text import RichText
def convert_to_streamfield(apps, schema_editor):
@ -586,7 +586,7 @@ If you change an existing RichTextField to a StreamField, the database migration
migrations.AlterField(
model_name='BlogPage',
name='body',
field=wagtail.core.fields.StreamField([('rich_text', wagtail.core.blocks.RichTextBlock())]),
field=wagtail.fields.StreamField([('rich_text', wagtail.blocks.RichTextBlock())]),
),
migrations.RunPython(
@ -606,7 +606,7 @@ Note that the above migration will work on published Page objects only. If you a
from django.core.serializers.json import DjangoJSONEncoder
from django.db import migrations, models
from wagtail.core.rich_text import RichText
from wagtail.rich_text import RichText
def page_to_streamfield(page):
@ -704,7 +704,7 @@ Note that the above migration will work on published Page objects only. If you a
migrations.AlterField(
model_name='BlogPage',
name='body',
field=wagtail.core.fields.StreamField([('rich_text', wagtail.core.blocks.RichTextBlock())]),
field=wagtail.fields.StreamField([('rich_text', wagtail.blocks.RichTextBlock())]),
),
migrations.RunPython(

Wyświetl plik

@ -38,7 +38,7 @@ Page content
The data/content entered into each page is accessed/output through Django's ``{{ double-brace }}`` notation. Each field from the model must be accessed by prefixing ``page.``. e.g the page title ``{{ page.title }}`` or another field ``{{ page.author }}``.
A custom variable name can be :attr:`configured on the page model <wagtail.core.models.Page.context_object_name>`. If a custom name is defined, ``page`` is still available for use in shared templates.
A custom variable name can be :attr:`configured on the page model <wagtail.models.Page.context_object_name>`. If a custom name is defined, ``page`` is still available for use in shared templates.
Additionally ``request.`` is available and contains Django's request object.
@ -299,4 +299,4 @@ Sometimes you may wish to vary the template output depending on whether the page
{% endif %}
If the page is being previewed, ``request.preview_mode`` can be used to determine the specific preview mode being used,
if the page supports :attr:`multiple preview modes <wagtail.core.models.Page.preview_modes>`.
if the page supports :attr:`multiple preview modes <wagtail.models.Page.preview_modes>`.

Wyświetl plik

@ -2,6 +2,8 @@
# also update scripts/nightly/get_version.py as well as that needs to generate a new
# version of this file from a template for nightly builds
import django
from wagtail.utils.version import get_semver_version, get_version
# major.minor.patch.release.number
@ -12,3 +14,21 @@ __version__ = get_version(VERSION)
# Required for npm package for frontend
__semver__ = get_semver_version(VERSION)
if django.VERSION >= (3, 2):
# The declaration is only needed for older Django versions
pass
else:
default_app_config = "wagtail.apps.WagtailCoreAppConfig"
def setup():
import warnings
from wagtail.utils.deprecation import removed_in_next_version_warning
warnings.simplefilter("default", removed_in_next_version_warning)
setup()

Wyświetl plik

@ -1,6 +1,6 @@
from django.core.exceptions import PermissionDenied
from wagtail.core.log_actions import log
from wagtail.log_actions import log
class ConvertAliasPageError(RuntimeError):

Wyświetl plik

@ -1,7 +1,7 @@
from django.core.exceptions import PermissionDenied
from django.db import transaction
from wagtail.core.coreutils import find_available_slug
from wagtail.coreutils import find_available_slug
class ParentNotTranslatedError(Exception):
@ -123,7 +123,7 @@ class CopyPageForTranslationAction:
def process_child_object(
original_page, page_copy, child_relation, child_object
):
from wagtail.core.models import TranslatableMixin
from wagtail.models import TranslatableMixin
if isinstance(child_object, TranslatableMixin):
child_object.locale = locale

Wyświetl plik

@ -4,12 +4,12 @@ import uuid
from django.core.exceptions import PermissionDenied
from modelcluster.models import get_all_child_relations
from wagtail.core.log_actions import log
from wagtail.core.models.copying import _copy, _copy_m2m_relations
from wagtail.core.models.i18n import TranslatableMixin
from wagtail.core.signals import page_published
from wagtail.log_actions import log
from wagtail.models.copying import _copy, _copy_m2m_relations
from wagtail.models.i18n import TranslatableMixin
from wagtail.signals import page_published
logger = logging.getLogger("wagtail.core")
logger = logging.getLogger("wagtail")
class CopyPageIntegrityError(RuntimeError):
@ -62,7 +62,7 @@ class CopyPageAction:
self.reset_translation_key = reset_translation_key
def check(self, skip_permission_checks=False):
from wagtail.core.models import UserPagePermissionsProxy
from wagtail.models import UserPagePermissionsProxy
# Essential data model checks
if self.page._state.adding:
@ -286,7 +286,7 @@ class CopyPageAction:
)
# Copy child pages
from wagtail.core.models import Page
from wagtail.models import Page
if self.recursive:
numchild = 0

Wyświetl plik

@ -3,11 +3,11 @@ import uuid
from django.core.exceptions import PermissionDenied
from wagtail.core.log_actions import log
from wagtail.core.models.copying import _copy, _copy_m2m_relations
from wagtail.core.models.i18n import TranslatableMixin
from wagtail.log_actions import log
from wagtail.models.copying import _copy, _copy_m2m_relations
from wagtail.models.i18n import TranslatableMixin
logger = logging.getLogger("wagtail.core")
logger = logging.getLogger("wagtail")
class CreatePageAliasIntegrityError(RuntimeError):
@ -213,7 +213,7 @@ class CreatePageAliasAction:
# Copy child pages
if recursive:
from wagtail.core.models import Page
from wagtail.models import Page
numchild = 0

Wyświetl plik

@ -1,6 +1,6 @@
from django.core.exceptions import PermissionDenied
from wagtail.core.log_actions import log
from wagtail.log_actions import log
class DeletePagePermissionError(PermissionDenied):
@ -27,7 +27,7 @@ class DeletePageAction:
)
def _delete_page(self, page, *args, **kwargs):
from wagtail.core.models import Page
from wagtail.models import Page
# Ensure that deletion always happens on an instance of Page, not a specific subclass. This
# works around a bug in treebeard <= 3.0 where calling SpecificPage.delete() fails to delete

Wyświetl plik

@ -4,10 +4,10 @@ from django.core.exceptions import PermissionDenied
from django.db import transaction
from treebeard.mp_tree import MP_MoveHandler
from wagtail.core.log_actions import log
from wagtail.core.signals import post_page_move, pre_page_move
from wagtail.log_actions import log
from wagtail.signals import post_page_move, pre_page_move
logger = logging.getLogger("wagtail.core")
logger = logging.getLogger("wagtail")
class MovePagePermissionError(PermissionDenied):
@ -33,7 +33,7 @@ class MovePageAction:
)
def _move_page(self, page, target, pos=None):
from wagtail.core.models import Page
from wagtail.models import Page
# Determine old and new parents
parent_before = page.get_parent()

Wyświetl plik

@ -4,10 +4,10 @@ from django.conf import settings
from django.core.exceptions import PermissionDenied
from django.utils import timezone
from wagtail.core.log_actions import log
from wagtail.core.signals import page_published
from wagtail.log_actions import log
from wagtail.signals import page_published
logger = logging.getLogger("wagtail.core")
logger = logging.getLogger("wagtail")
class PublishPagePermissionError(PermissionDenied):
@ -73,7 +73,7 @@ class PublishPageRevisionAction:
def _publish_page_revision(
self, revision, page, user, changed, log_action, previous_revision
):
from wagtail.core.models import COMMENTS_RELATION_NAME, PageRevision
from wagtail.models import COMMENTS_RELATION_NAME, PageRevision
if page.go_live_at and page.go_live_at > timezone.now():
page.has_unpublished_changes = True

Wyświetl plik

@ -2,10 +2,10 @@ import logging
from django.core.exceptions import PermissionDenied
from wagtail.core.log_actions import log
from wagtail.core.signals import page_unpublished
from wagtail.log_actions import log
from wagtail.signals import page_unpublished
logger = logging.getLogger("wagtail.core")
logger = logging.getLogger("wagtail")
class UnpublishPagePermissionError(PermissionDenied):
@ -92,7 +92,7 @@ class UnpublishPageAction:
)
if self.include_descendants:
from wagtail.core.models import UserPagePermissionsProxy
from wagtail.models import UserPagePermissionsProxy
user_perms = UserPagePermissionsProxy(self.user)
for live_descendant_page in (

Wyświetl plik

@ -6,9 +6,9 @@ from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from wagtail import hooks
from wagtail.admin.ui.components import Component
from wagtail.core import hooks
from wagtail.core.models import UserPagePermissionsProxy
from wagtail.models import UserPagePermissionsProxy
class ActionMenuItem(Component):

Wyświetl plik

@ -2,7 +2,7 @@ from django.contrib.admin.utils import quote
from django.core.exceptions import ImproperlyConfigured
from django.urls import reverse
from wagtail.core.hooks import search_for_hooks
from wagtail.hooks import search_for_hooks
from wagtail.utils.registry import ObjectTypeRegistry
"""

Wyświetl plik

@ -4,11 +4,8 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.actions.convert_alias import ConvertAliasPageAction, ConvertAliasPageError
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.convert_alias import (
ConvertAliasPageAction,
ConvertAliasPageError,
)
from .base import APIAction

Wyświetl plik

@ -5,10 +5,10 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.actions.copy_page import CopyPageAction, CopyPageIntegrityError
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.copy_page import CopyPageAction, CopyPageIntegrityError
from wagtail.core.coreutils import find_available_slug
from wagtail.core.models import Page
from wagtail.coreutils import find_available_slug
from wagtail.models import Page
from .base import APIAction

Wyświetl plik

@ -5,12 +5,12 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.copy_for_translation import (
from wagtail.actions.copy_for_translation import (
CopyPageForTranslationAction,
ParentNotTranslatedError,
)
from wagtail.core.models.i18n import Locale
from wagtail.api.v2.utils import BadRequestError
from wagtail.models.i18n import Locale
from .base import APIAction

Wyświetl plik

@ -5,12 +5,12 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.create_alias import (
from wagtail.actions.create_alias import (
CreatePageAliasAction,
CreatePageAliasIntegrityError,
)
from wagtail.core.models import Page
from wagtail.api.v2.utils import BadRequestError
from wagtail.models import Page
from .base import APIAction

Wyświetl plik

@ -4,7 +4,7 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.core.actions.delete_page import DeletePageAction
from wagtail.actions.delete_page import DeletePageAction
from .base import APIAction

Wyświetl plik

@ -5,8 +5,8 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.core.actions.move_page import MovePageAction
from wagtail.core.models import Page
from wagtail.actions.move_page import MovePageAction
from wagtail.models import Page
from .base import APIAction

Wyświetl plik

@ -4,8 +4,8 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.actions.publish_page_revision import PublishPageRevisionAction
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.publish_page_revision import PublishPageRevisionAction
from .base import APIAction

Wyświetl plik

@ -5,11 +5,11 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.api.v2.utils import BadRequestError
from wagtail.core.actions.revert_to_page_revision import (
from wagtail.actions.revert_to_page_revision import (
RevertToPageRevisionAction,
RevertToPageRevisionError,
)
from wagtail.api.v2.utils import BadRequestError
from .base import APIAction

Wyświetl plik

@ -4,7 +4,7 @@ from rest_framework.exceptions import ValidationError
from rest_framework.response import Response
from rest_framework.serializers import Serializer
from wagtail.core.actions.unpublish_page import UnpublishPageAction
from wagtail.actions.unpublish_page import UnpublishPageAction
from .base import APIAction

Wyświetl plik

@ -1,8 +1,8 @@
from rest_framework.filters import BaseFilterBackend
from wagtail import hooks
from wagtail.api.v2.utils import BadRequestError, parse_boolean
from wagtail.core import hooks
from wagtail.core.models import UserPagePermissionsProxy
from wagtail.models import UserPagePermissionsProxy
class HasChildrenFilter(BaseFilterBackend):

Wyświetl plik

@ -4,7 +4,7 @@ from rest_framework.fields import Field, ReadOnlyField
from wagtail.api.v2.serializers import PageSerializer, get_serializer_class
from wagtail.api.v2.utils import get_full_url
from wagtail.core.models import Page
from wagtail.models import Page
def get_model_listing_url(context, model):

Wyświetl plik

@ -1,7 +1,7 @@
from django.urls import path
from wagtail import hooks
from wagtail.api.v2.router import WagtailAPIRouter
from wagtail.core import hooks
from .views import PagesAdminAPIViewSet

Wyświetl plik

@ -7,7 +7,7 @@ from rest_framework.authentication import SessionAuthentication
from rest_framework.response import Response
from wagtail.api.v2.views import PagesAPIViewSet
from wagtail.core.models import Page
from wagtail.models import Page
from .actions.convert_alias import ConvertAliasPageAPIAction
from .actions.copy import CopyPageAPIAction

Wyświetl plik

@ -12,8 +12,8 @@ from django.utils.translation import gettext as _
from django.utils.translation import override
from wagtail.admin import messages
from wagtail.core.log_actions import LogContext
from wagtail.core.models import GroupPagePermission
from wagtail.log_actions import LogContext
from wagtail.models import GroupPagePermission
def users_with_page_permission(page, permission_type, include_superusers=True):

Wyświetl plik

@ -1,7 +1,7 @@
import warnings
from wagtail.core.blocks import * # noqa
from wagtail.blocks import * # noqa
warnings.warn(
"wagtail.admin.blocks has moved to wagtail.core.blocks", UserWarning, stacklevel=2
"wagtail.admin.blocks has moved to wagtail.blocks", UserWarning, stacklevel=2
)

Wyświetl plik

@ -36,7 +36,7 @@ def css_install_check(app_configs, **kwargs):
@register(Tags.admin)
def base_form_class_check(app_configs, **kwargs):
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.core.models import get_page_models
from wagtail.models import get_page_models
errors = []
@ -61,7 +61,7 @@ def base_form_class_check(app_configs, **kwargs):
@register(Tags.admin)
def get_form_class_check(app_configs, **kwargs):
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.core.models import get_page_models
from wagtail.models import get_page_models
errors = []
@ -86,7 +86,7 @@ def get_form_class_check(app_configs, **kwargs):
@register("panels")
def inline_panel_model_panels_check(app_configs, **kwargs):
from wagtail.core.models import get_page_models
from wagtail.models import get_page_models
errors = []
page_models = get_page_models()
@ -105,7 +105,7 @@ def inline_panel_model_panels_check(app_configs, **kwargs):
def check_panels_in_model(cls, context="model"):
"""Check panels configuration uses `panels` when `edit_handler` not in use."""
from wagtail.admin.edit_handlers import BaseCompositeEditHandler, InlinePanel
from wagtail.core.models import Page
from wagtail.models import Page
errors = []

Wyświetl plik

@ -10,8 +10,8 @@ from django.utils.text import capfirst
from django.utils.translation import gettext_lazy as _
from taggit.managers import TaggableManager
from wagtail.core import blocks
from wagtail.core.fields import RichTextField, StreamField
from wagtail import blocks
from wagtail.fields import RichTextField, StreamField
from wagtail.utils.registry import ModelFieldRegistry

Wyświetl plik

@ -19,9 +19,9 @@ from modelcluster.models import get_serializable_data_for_fields
from wagtail.admin import compare, widgets
from wagtail.admin.forms.comments import CommentForm, CommentReplyForm
from wagtail.admin.templatetags.wagtailadmin_tags import avatar_url, user_display_name
from wagtail.core.blocks import BlockField
from wagtail.core.coreutils import camelcase_to_underscore
from wagtail.core.models import COMMENTS_RELATION_NAME, Page
from wagtail.blocks import BlockField
from wagtail.coreutils import camelcase_to_underscore
from wagtail.models import COMMENTS_RELATION_NAME, Page
from wagtail.utils.decorators import cached_classmethod
# DIRECT_FORM_FIELD_OVERRIDES, FORM_FIELD_OVERRIDES are imported for backwards

Wyświetl plik

@ -9,7 +9,7 @@ from wagtail.admin.widgets import (
ButtonSelect,
FilteredSelect,
)
from wagtail.core.coreutils import get_content_type_label
from wagtail.coreutils import get_content_type_label
class DateRangePickerWidget(SuffixedMultiWidget):

Wyświetl plik

@ -13,7 +13,7 @@ from wagtail.admin.localization import (
get_available_admin_time_zones,
)
from wagtail.admin.widgets import SwitchInput
from wagtail.core.models import UserPagePermissionsProxy
from wagtail.models import UserPagePermissionsProxy
from wagtail.users.models import UserProfile
User = get_user_model()

Wyświetl plik

@ -9,7 +9,7 @@ from django.template.loader import render_to_string
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from wagtail.core.models import (
from wagtail.models import (
Collection,
CollectionViewRestriction,
GroupCollectionPermission,

Wyświetl plik

@ -12,7 +12,7 @@ from taggit.managers import TaggableManager
from wagtail.admin import widgets
from wagtail.admin.forms.tags import TagField
from wagtail.core.models import Page
from wagtail.models import Page
from wagtail.utils.registry import ModelFieldRegistry
# Define a registry of form field properties to override for a given model field

Wyświetl plik

@ -5,7 +5,7 @@ from django.utils.translation import gettext as _
from django.utils.translation import ngettext
from wagtail.admin import widgets
from wagtail.core.models import Page, PageViewRestriction
from wagtail.models import Page, PageViewRestriction
from .models import WagtailAdminModelForm
from .view_restrictions import BaseViewRestrictionForm

Wyświetl plik

@ -3,7 +3,7 @@ from django.contrib.auth.models import Group
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
from wagtail.core.models import BaseViewRestriction
from wagtail.models import BaseViewRestriction
class BaseViewRestrictionForm(forms.ModelForm):

Wyświetl plik

@ -8,8 +8,8 @@ from wagtail.admin import widgets
from wagtail.admin.edit_handlers import FieldPanel, InlinePanel, ObjectList
from wagtail.admin.forms import WagtailAdminModelForm
from wagtail.admin.widgets.workflows import AdminTaskChooser
from wagtail.core.coreutils import get_model_string
from wagtail.core.models import Page, Task, Workflow, WorkflowPage
from wagtail.coreutils import get_model_string
from wagtail.models import Page, Task, Workflow, WorkflowPage
class TaskChooserSearchForm(forms.Form):

Wyświetl plik

@ -8,8 +8,8 @@ from django.template.loader import render_to_string
from django.utils.translation import override
from wagtail.admin.auth import users_with_page_permission
from wagtail.core.coreutils import camelcase_to_underscore
from wagtail.core.models import GroupApprovalTask, TaskState, WorkflowState
from wagtail.coreutils import camelcase_to_underscore
from wagtail.models import GroupApprovalTask, TaskState, WorkflowState
from wagtail.users.models import UserProfile
logger = logging.getLogger("wagtail.admin")

Wyświetl plik

@ -3,10 +3,10 @@ from django.forms.utils import flatatt
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
from wagtail import hooks
from wagtail.admin.ui.sidebar import LinkMenuItem as LinkMenuItemComponent
from wagtail.admin.ui.sidebar import SubMenuItem as SubMenuItemComponent
from wagtail.core import hooks
from wagtail.core.coreutils import cautious_slugify
from wagtail.coreutils import cautious_slugify
class MenuItem(metaclass=MediaDefiningClass):

Wyświetl plik

@ -8,7 +8,7 @@ from taggit.models import Tag
# wagtail.admin.models ensures that this happens in advance of running wagtail.admin's
# system checks.
from wagtail.admin import edit_handlers # NOQA
from wagtail.core.models import Page
from wagtail.models import Page
# A dummy model that exists purely to attach the access_admin permission type to, so that it

Wyświetl plik

@ -1,6 +1,6 @@
from django.conf import settings
from wagtail.core.models import Page
from wagtail.models import Page
def get_pages_with_direct_explore_permission(user):

Wyświetl plik

@ -10,8 +10,8 @@ from wagtail.admin.rich_text.converters.html_to_contentstate import (
BLOCK_KEY_NAME,
HtmlToContentStateHandler,
)
from wagtail.core.rich_text import features as feature_registry
from wagtail.core.whitelist import check_url
from wagtail.rich_text import features as feature_registry
from wagtail.whitelist import check_url
def link_entity(props):

Wyświetl plik

@ -1,14 +1,10 @@
from django.utils.functional import cached_property
from django.utils.html import escape
from wagtail.core.models import Page
from wagtail.core.rich_text import features as feature_registry
from wagtail.core.rich_text.rewriters import (
EmbedRewriter,
LinkRewriter,
MultiRuleRewriter,
)
from wagtail.core.whitelist import Whitelister, allow_without_attributes
from wagtail.models import Page
from wagtail.rich_text import features as feature_registry
from wagtail.rich_text.rewriters import EmbedRewriter, LinkRewriter, MultiRuleRewriter
from wagtail.whitelist import Whitelister, allow_without_attributes
class WhitelistRule:

Wyświetl plik

@ -9,8 +9,8 @@ from wagtail.admin.rich_text.converters.contentstate_models import (
InlineStyleRange,
)
from wagtail.admin.rich_text.converters.html_ruleset import HTMLRuleset
from wagtail.core.models import Page
from wagtail.core.rich_text import features as feature_registry
from wagtail.models import Page
from wagtail.rich_text import features as feature_registry
# constants to keep track of what to do with leading whitespace on the next text node we encounter
STRIP_WHITESPACE = 0

Wyświetl plik

@ -6,9 +6,9 @@ from django.utils.functional import cached_property
from wagtail.admin.rich_text.converters.contentstate import ContentstateConverter
from wagtail.admin.staticfiles import versioned_static
from wagtail.core.rich_text import features as feature_registry
from wagtail.core.telepath import register
from wagtail.core.widget_adapters import WidgetAdapter
from wagtail.rich_text import features as feature_registry
from wagtail.telepath import register
from wagtail.widget_adapters import WidgetAdapter
class DraftailRichTextArea(widgets.HiddenInput):

Wyświetl plik

@ -3,7 +3,7 @@ from django.forms import Media
from wagtail.admin.staticfiles import versioned_static
# Feature objects: these are mapped to feature identifiers within the rich text
# feature registry (wagtail.core.rich_text.features). Each one implements
# feature registry (wagtail.rich_text.features). Each one implements
# a `construct_options` method which modifies an options dict as appropriate to
# enable that feature.

Wyświetl plik

@ -5,8 +5,8 @@ from django.utils.functional import cached_property, total_ordering
from django.utils.safestring import mark_safe
from django.utils.text import slugify
from wagtail import hooks
from wagtail.admin.forms.search import SearchForm
from wagtail.core import hooks
@total_ordering

Wyświetl plik

@ -4,8 +4,8 @@ from wagtail.admin.mail import (
WorkflowStateRejectionEmailNotifier,
WorkflowStateSubmissionEmailNotifier,
)
from wagtail.core.models import TaskState, WorkflowState
from wagtail.core.signals import (
from wagtail.models import TaskState, WorkflowState
from wagtail.signals import (
task_submitted,
workflow_approved,
workflow_rejected,

Wyświetl plik

@ -1,10 +1,10 @@
from django.forms import Media
from wagtail import hooks
from wagtail.admin.auth import user_has_any_page_permission
from wagtail.admin.navigation import get_site_for_user
from wagtail.admin.ui.components import Component
from wagtail.core import hooks
from wagtail.core.models import Page, Site
from wagtail.models import Page, Site
class SummaryItem(Component):

Wyświetl plik

@ -23,6 +23,7 @@ from django.utils.safestring import mark_safe
from django.utils.timesince import timesince
from django.utils.translation import gettext_lazy as _
from wagtail import hooks
from wagtail.admin.localization import get_js_translation_strings
from wagtail.admin.menu import admin_menu
from wagtail.admin.navigation import get_explorable_root_page
@ -32,15 +33,14 @@ from wagtail.admin.ui import sidebar
from wagtail.admin.views.bulk_action.registry import bulk_action_registry
from wagtail.admin.views.pages.utils import get_valid_next_url_from_request
from wagtail.admin.widgets import ButtonWithDropdown, PageListingButton
from wagtail.core import hooks
from wagtail.core.coreutils import camelcase_to_underscore
from wagtail.core.coreutils import cautious_slugify as _cautious_slugify
from wagtail.core.coreutils import (
from wagtail.coreutils import camelcase_to_underscore
from wagtail.coreutils import cautious_slugify as _cautious_slugify
from wagtail.coreutils import (
escape_script,
get_content_type_label,
get_locales_display_names,
)
from wagtail.core.models import (
from wagtail.models import (
Collection,
CollectionViewRestriction,
Locale,
@ -48,7 +48,7 @@ from wagtail.core.models import (
PageViewRestriction,
UserPagePermissionsProxy,
)
from wagtail.core.telepath import JSContext
from wagtail.telepath import JSContext
from wagtail.users.utils import get_gravatar_url
register = template.Library()

Wyświetl plik

@ -2,6 +2,7 @@ from django import template
from django.template.loader import render_to_string
from django.utils import translation
from wagtail import hooks
from wagtail.admin.userbar import (
AddPageItem,
AdminItem,
@ -10,8 +11,7 @@ from wagtail.admin.userbar import (
ExplorePageItem,
RejectModerationEditPageItem,
)
from wagtail.core import hooks
from wagtail.core.models import PAGE_TEMPLATE_VAR, Page, PageRevision
from wagtail.models import PAGE_TEMPLATE_VAR, Page, PageRevision
from wagtail.users.models import UserProfile
register = template.Library()

Wyświetl plik

@ -7,9 +7,9 @@ from django.contrib.auth.models import Group, Permission
from django.urls import reverse
from django.utils import timezone
from wagtail import hooks
from wagtail.api.v2.tests.test_pages import TestPageDetail, TestPageListing
from wagtail.core import hooks
from wagtail.core.models import GroupPagePermission, Locale, Page, PageLogEntry
from wagtail.models import GroupPagePermission, Locale, Page, PageLogEntry
from wagtail.test.demosite import models
from wagtail.test.testapp.models import EventIndex, EventPage, SimplePage, StreamPage
from wagtail.users.models import UserProfile

Wyświetl plik

@ -4,7 +4,7 @@ from django.test import TestCase
from django.urls import reverse
from django.utils import timezone
from wagtail.core.models import Page, Site
from wagtail.models import Page, Site
from wagtail.test.benchmark import Benchmark
from wagtail.test.testapp.models import SingleEventPage, StreamPage
from wagtail.test.utils import WagtailTestUtils

Some files were not shown because too many files have changed in this diff Show More