모델 참조

이 문서는 wagtail.models 모듈 내의 모델 클래스에 대한 참조 정보를 포함합니다.

Page

데이터베이스 필드

class wagtail.models.Page
title

(텍스트)

페이지의 사람이 읽을 수 있는 제목입니다.

draft_title

(텍스트)

페이지의 사람이 읽을 수 있는 제목으로, 초안 편집에서 변경된 내용을 포함합니다(게시된 페이지의 경우 title 필드는 현재 게시된 버전의 제목임).

slug

(텍스트)

페이지의 URL을 구성하는 데 사용됩니다.

예: http://domain.com/blog/[my-slug]/

content_type

(django.contrib.contenttypes.models.ContentType 에 대한 외래 키)

이 페이지의 특정 모델을 나타내는 ContentType 객체에 대한 외래 키입니다.

live

(부울)

페이지가 게시된 경우 True 로 설정되는 부울입니다.

참고: 이 필드는 기본적으로 True 로 설정되어 프로그래밍 방식으로 생성된 모든 페이지가 기본적으로 게시됩니다.

has_unpublished_changes

(부울)

페이지가 초안이거나 초안 변경 사항과 함께 게시된 경우 True 로 설정되는 부울입니다.

owner

(사용자 모델에 대한 외래 키)

페이지를 만든 사용자에 대한 외래 키입니다.

first_published_at

(날짜/시간)

페이지가 처음 게시된 날짜/시간입니다.

last_published_at

(날짜/시간)

페이지가 마지막으로 게시된 날짜/시간입니다.

seo_title

(텍스트)

페이지의 <title> HTML 태그에 사용하기 위한 대체 SEO 최적화 제목입니다.

search_description

(텍스트)

검색 색인에 사용되는 콘텐츠의 SEO 최적화 설명입니다. 페이지의 <meta name="description"> HTML 태그에도 적합합니다.

show_in_menus

(부울)

페이지가 사이트 전체 메뉴에 포함되어야 하는지 여부를 전환하며, 페이지 편집기의 promote_panels 에 표시됩니다.

Wagtail은 기본적으로 메뉴 구현을 포함하지 않으므로, 이 필드는 특정 Wagtail 설치에서 그렇게 구축되지 않는 한 프런트엔드 콘텐츠에서 아무것도 하지 않습니다.

그러나 이는 in_menu() QuerySet 필터에서 이 필드를 사용하는 페이지를 더 쉽게 쿼리하는 데 사용됩니다.

기본값은 False 이며, 모델에서 show_in_menus_default = True 로 재정의할 수 있습니다.

참고

모든 페이지에 대한 전역 기본값을 설정하려면 Page 모델을 처음 가져올 때 Page.show_in_menus_default = True 를 한 번 설정하십시오.

locked

(부울)

True 로 설정되면 Wagtail 편집기는 어떤 사용자도 페이지의 콘텐츠를 편집할 수 없습니다.

locked_by 도 설정된 경우 해당 사용자만 페이지를 편집할 수 있습니다.

locked_by

(사용자 모델에 대한 외래 키)

현재 페이지를 잠근 사용자입니다. 이 사용자만 페이지를 편집할 수 있습니다.

lockedTrue 일 때 이것이 None 이면 아무도 페이지를 편집할 수 없습니다.

locked_at

(날짜/시간)

페이지가 잠긴 날짜/시간입니다.

alias_of

(다른 페이지에 대한 외래 키)

설정된 경우 이 페이지는 이 필드에서 참조되는 페이지의 별칭입니다.

locale

(Locale에 대한 외래 키)

이 외래 키는 페이지 언어를 나타내는 Locale 객체에 연결됩니다.

translation_key

(uuid)

새 페이지가 생성될 때마다 무작위로 생성되는 UUID입니다. 이는 해당 인스턴스의 모든 번역과 공유되므로 번역을 쿼리하는 데 사용할 수 있습니다.

translation_key 값은 각 로케일의 한 페이지에서만 사용할 수 있습니다.

메서드 및 속성

제공된 모델 필드 외에도 Page 에는 자체 모델을 만들 때 참조, 사용 또는 재정의할 수 있는 많은 속성 및 메서드가 있습니다.

참고

django-treebeard노드 API도 참조하십시오. Pagematerialized path tree 노드의 서브클래스입니다.

class wagtail.models.Page
get_specific(deferred=False, copy_attrs=None, copy_attrs_exclude=None)

Return this object in its most specific subclassed form.

By default, a database query is made to fetch all field values for the specific object. If you only require access to custom methods or other non-field attributes on the specific object, you can use deferred=True to avoid this query. However, any attempts to access specific field values from the returned object will trigger additional database queries.

By default, references to all non-field attribute values are copied from current object to the returned one. This includes:

  • Values set by a queryset, for example: annotations, or values set as a result of using select_related() or prefetch_related().

  • Any cached_property values that have been evaluated.

  • Attributes set elsewhere in Python code.

For fine-grained control over which non-field values are copied to the returned object, you can use copy_attrs to specify a complete list of attribute names to include. Alternatively, you can use copy_attrs_exclude to specify a list of attribute names to exclude.

If called on an object that is already an instance of the most specific class, the object will be returned as is, and no database queries or other operations will be triggered.

If the object was originally created using a model that has since been removed from the codebase, an instance of the base class will be returned (without any custom field values or other functionality present on the original class). Usually, deleting these objects is the best course of action, but there is currently no safe way for Wagtail to do that at migration time.

specific

Returns this object in its most specific subclassed form with all field values fetched from the database. The result is cached in memory.

specific_deferred

Returns this object in its most specific subclassed form without any additional field values being fetched from the database. The result is cached in memory.

specific_class

Return the class that this object would be if instantiated in its most specific form.

If the model class can no longer be found in the codebase, and the relevant ContentType has been removed by a database migration, the return value will be None.

If the model class can no longer be found in the codebase, but the relevant ContentType is still present in the database (usually a result of switching between git branches without running or reverting database migrations beforehand), the return value will be None.

cached_content_type

Return this object’s content_type value from the ContentType model’s cached manager, which will avoid a database query if the content type is already in memory.

page_type_display_name

A human-readable version of this page’s type.

get_url(request=None, current_site=None)

Return the ‘most appropriate’ URL for referring to this page from the pages we serve, within the Wagtail backend and actual website templates; this is the local URL (starting with ‘/’) if we’re only running a single site (i.e. we know that whatever the current page is being served from, this link will be on the same domain), and the full URL (with domain) if not. Return None if the page is not routable.

Accepts an optional but recommended request keyword argument that, if provided, will be used to cache site-level URL information (thereby avoiding repeated database / cache lookups) and, via the Site.find_for_request() function, determine whether a relative or full URL is most appropriate.

get_full_url(request=None)

Return the full URL (including protocol / domain) to this page, or None if it is not routable.

full_url

Return the full URL (including protocol / domain) to this page, or None if it is not routable.

relative_url(current_site, request=None)

Return the ‘most appropriate’ URL for this page taking into account the site we’re currently on; a local URL if the site matches, or a fully qualified one otherwise. Return None if the page is not routable.

Accepts an optional but recommended request keyword argument that, if provided, will be used to cache site-level URL information (thereby avoiding repeated database / cache lookups).

get_site()

Return the Site object that this page belongs to.

get_url_parts(request=None)

Determine the URL for this page and return it as a tuple of (site_id, site_root_url, page_url_relative_to_site_root). Return None if the page is not routable, or return (site_id, None, None) if NoReverseMatch exception is raised.

This is used internally by the full_url, url, relative_url and get_site properties and methods; pages with custom URL routing should override this method in order to have those operations return the custom URLs.

Accepts an optional keyword argument request, which may be used to avoid repeated database / cache lookups. Typically, a page model that overrides get_url_parts should not need to deal with request directly, and should just pass it to the original method when calling super.

route(request, path_components)
serve(request, *args, **kwargs)
static route_for_request(request: HttpRequest, path: str) RouteResult | None

Find the page route for the given HTTP request object, and URL path. The route result (page, args, and kwargs) will be cached via request._wagtail_route_for_request.

static find_for_request(request: HttpRequest, path: str) Page | None

Find the page for the given HTTP request object, and URL path. The full page route will be cached via request._wagtail_route_for_request.

get_default_privacy_setting(request)

페이지의 기본 개인 정보 설정을 지정합니다.

이 메서드는 최소한 ‘type’ 키가 있는 사전을 반환해야 합니다. 값은 PageViewRestrictionrestriction_type 에서 다음 값 중 하나여야 합니다.

  • BaseViewRestriction.NONE: 페이지가 공개되어 누구나 액세스할 수 있습니다. (기본값) - ‘{“type”: BaseViewRestriction.NONE}’

  • BaseViewRestriction.LOGIN: 페이지가 비공개이며 인증된 사용자만 액세스할 수 있습니다. - ‘{“type”: BaseViewRestriction.LOGIN}’

  • BaseViewRestriction.PASSWORD: 페이지가 비공개이며 공유 암호가 있는 사용자만 액세스할 수 있습니다. (사전에 추가 password 키 필요) - ‘{“type”: BaseViewRestriction.PASSWORD, “password”: “P@ssw0rd123!”}’

  • BaseViewRestriction.GROUPS: 페이지가 비공개이며 특정 그룹의 사용자만 액세스할 수 있습니다. (그룹 객체 목록이 있는 추가 groups 키 필요) - ‘{“type”: BaseViewRestriction.GROUPS, “groups”: [moderators, editors]}’

예시

class BreadsIndexPage(Page):
    #...

    def get_default_privacy_setting(request):
        from wagtail.models import BaseViewRestriction
        # 편집자가 foo.add_bar 권한을 가지고 있다면 기본값을 중재자 및 편집자 그룹이 체크된 그룹으로 설정합니다.
        if request.user.has_perm("foo.add_bar"):
            moderators = Group.objects.filter(name="Moderators").first()
            editors = Group.objects.filter(name="Editors").first()
            return {"type": BaseViewRestriction.GROUPS, "groups": [moderators,editors]}
        else:
            return {"type": BaseViewRestriction.NONE}
context_object_name = None

페이지의 Context 에서 페이지 인스턴스에 대한 사용자 지정 이름입니다.

get_context(request, *args, **kwargs)
get_template(request, *args, **kwargs)
get_admin_display_title()

Return the title for this page as it should appear in the admin backend; override this if you wish to display extra contextual information about the page, such as language. By default, returns draft_title.

allowed_http_methods = [<HTTPMethod.DELETE>, <HTTPMethod.GET>, <HTTPMethod.HEAD>, <HTTPMethod.OPTIONS>, <HTTPMethod.PATCH>, <HTTPMethod.POST>, <HTTPMethod.PUT>]

이 속성을 사용자 지정할 때 개발자는 Python의 내장 http.HTTPMethod 열거형의 값을 목록에 사용하는 것이 좋습니다. 더 강력하고 이미 메모리에 존재하는 값을 사용하기 때문입니다. 예를 들어:

from http import HTTPMethod

class MyPage(Page):
    allowed_http_methods = [HTTPMethod.GET, HTTPMethod.OPTIONS]

http.HTTPMethod 열거형은 Python 3.11까지 추가되지 않았으므로 프로젝트에서 이전 버전의 Python을 사용하는 경우 대신 대문자 문자열을 사용할 수 있습니다. 예를 들어:

class MyPage(Page):
    allowed_http_methods = ["GET", "OPTIONS"]
check_request_method(request, *args, **kwargs)

Checks the method attribute of the request against those supported by the page (as defined by allowed_http_methods) and responds accordingly.

If supported, None is returned, and the request is processed normally. If not, a warning is logged and an HttpResponseNotAllowed is returned, and any further request handling is terminated.

handle_options_request(request, *args, **kwargs)

Returns an HttpResponse with an "Allow" header containing the list of supported HTTP methods for this page. This method is used instead of serve() to handle requests when the OPTIONS HTTP verb is detected (and HTTPMethod.OPTIONS is present in allowed_http_methods for this type of page).

preview_modes

A list of (internal_name, display_name) tuples for the modes in which this object can be displayed for preview/moderation purposes. Ordinarily an object will only have one display mode, but subclasses can override this - for example, a page containing a form might have a default view of the form, and a post-submission ‘thank you’ page. Set to [] to completely disable previewing for this model.

default_preview_mode

The default preview mode to use in live preview. This default is also used in areas that do not give the user the option of selecting a mode explicitly, e.g. in the moderator approval workflow. If preview_modes is empty, an IndexError will be raised.

preview_sizes

A list of dictionaries, each representing a preview size option for this object. Override this property to customize the preview sizes. Each dictionary in the list should include the following keys:

  • name: A string representing the internal name of the preview size.

  • icon: A string specifying the icon’s name for the preview size button.

  • device_width: An integer indicating the device’s width in pixels.

  • label: A string for the aria label on the preview size button.

@property
def preview_sizes(self):
    return [
        {
            "name": "mobile",
            "icon": "mobile-icon",
            "device_width": 320,
            "label": "Preview in mobile size"
        },
        # Add more preview size dictionaries as needed.
    ]
default_preview_size

The default preview size name to use in live preview. Defaults to "mobile", which is the first one defined in preview_sizes. If preview_sizes is empty, an IndexError will be raised.

serve_preview(request, mode_name)

Returns an HTTP response for use in object previews.

This method can be overridden to implement custom rendering and/or routing logic.

Any templates rendered during this process should use the request object passed here - this ensures that request.user and other properties are set appropriately for the wagtail user bar to be displayed/hidden. This request will always be a GET.

get_parent(update=False)
반환:

the parent node of the current node object. Caches the result in the object itself to help in loops.

get_children()
반환:

A queryset of all the node’s children

get_ancestors(inclusive=False)

Returns a queryset of the current page’s ancestors, starting at the root page and descending to the parent, or to the current page itself if inclusive is true.

get_descendants(inclusive=False)

Returns a queryset of all pages underneath the current page, any number of levels deep. If inclusive is true, the current page itself is included in the queryset.

get_siblings(inclusive=True)

Returns a queryset of all other pages with the same parent as the current page. If inclusive is true, the current page itself is included in the queryset.

get_translations(inclusive=False)

Returns a queryset containing the translations of this instance.

get_translation(locale)

Finds the translation in the specified locale.

If there is no translation in that locale, this raises a model.DoesNotExist exception.

get_translation_or_none(locale)

Finds the translation in the specified locale.

If there is no translation in that locale, this returns None.

has_translation(locale)

Returns True if a translation exists in the specified locale.

copy_for_translation(locale, copy_parents=False, alias=False, exclude_fields=None)

Creates a copy of this page in the specified locale.

get_admin_default_ordering()

관리자 페이지 색인을 보고 검색 결과를 보지 않을 때 자식 페이지의 기본 정렬 순서를 반환합니다.

다음 정렬 순서를 사용할 수 있습니다.

  • 'content_type'

  • '-content_type'

  • 'latest_revision_created_at'

  • '-latest_revision_created_at'

  • 'live'

  • '-live'

  • 'ord'

  • 'title'

  • '-title'

예를 들어, 페이지 수가 20개 미만인 경우에만 모든 자식 페이지에 대해 제목별로 페이지를 정렬하도록 합니다.

class BreadsIndexPage(Page):
    def get_admin_default_ordering(self):
        if Page.objects.child_of(self).count() < 20:
            return 'title'
        return self.admin_default_ordering
admin_default_ordering

메서드 get_admin_default_ordering() 에 대한 속성 버전으로, 기본값은 '-latest_revision_created_at' 입니다.

localized

Finds the translation in the current active language.

If there is no translation in the active language, self is returned.

Note: This will not return the translation if it is in draft. If you want to include drafts, use the .localized_draft attribute instead.

localized_draft

Finds the translation in the current active language.

If there is no translation in the active language, self is returned.

Note: This will return translations that are in draft. If you want to exclude these, use the .localized attribute.

search_fields

검색 엔진에서 색인화할 필드 목록입니다. 검색 문서 추가 필드 색인화 를 참조하십시오.

subpage_types

이 페이지 유형의 자식으로 생성할 수 있는 페이지 모델 목록입니다. 예를 들어, BlogIndex 페이지는 BlogPage 를 자식으로 허용할 수 있지만 JobPage 는 허용하지 않습니다.

class BlogIndex(Page):
    subpage_types = ['mysite.BlogPage', 'mysite.BlogArchivePage']

주어진 페이지에 대한 자식 페이지 생성을 완전히 차단하려면 subpage_types 속성을 빈 배열로 설정합니다.

class BlogPage(Page):
    subpage_types = []
parent_page_types

부모 페이지 유형으로 허용되는 페이지 모델 목록입니다. 예를 들어, BlogPageBlogIndex 페이지 아래에서만 생성할 수 있습니다.

class BlogPage(Page):
    parent_page_types = ['mysite.BlogIndexPage']

페이지는 parent_page_types 를 빈 배열로 설정하여 전혀 생성되지 않도록 할 수 있습니다(이는 한 번만 생성되어야 하는 고유한 페이지를 만드는 데 유용합니다).

class HiddenPage(Page):
    parent_page_types = []

루트 페이지 아래에서만 페이지를 생성할 수 있도록 하려면(예: HomePage 모델의 경우) parent_page_type['wagtailcore.Page'] 로 설정합니다.

class HomePage(Page):
    parent_page_types = ['wagtailcore.Page']
classmethod can_exist_under(parent)

Checks if this page type can exist as a subpage under a parent page instance.

See also: Page.can_create_at() and Page.can_move_to()

classmethod can_create_at(parent)

Checks if this page type can be created as a subpage under a parent page instance.

can_move_to(parent)

Checks if this page instance can be moved to be a subpage of a parent page instance.

get_route_paths()

Returns a list of paths that this page can be viewed at.

These values are combined with the dynamic portion of the page URL to automatically create redirects when the page’s URL changes.

참고

If using RoutablePageMixin, you may want to override this method to include the paths of popular routes.

참고

Redirect paths are ‘normalized’ to apply consistent ordering to GET parameters, so you don’t need to include every variation. Fragment identifiers are discarded too, so should be avoided.

password_required_template

이 모델을 사용하는 보호된 페이지에 대한 로그인 폼을 렌더링하는 데 사용될 템플릿 파일을 정의합니다. 이는 설정에서 WAGTAIL_PASSWORD_REQUIRED_TEMPLATE 을 사용하여 정의된 기본값을 재정의합니다. 비공개 페이지 를 참조하십시오.

is_creatable

이 페이지를 Wagtail 관리를 통해 생성할 수 있는지 여부를 제어합니다. 기본값은 True 이며, 서브클래스에 의해 상속되지 않습니다. 이는 multi-table inheritance 를 사용할 때 기본 모델이 실제 페이지로 생성되는 것을 막는 데 유용합니다.

max_count

Wagtail 관리 인터페이스를 통해 생성할 수 있는 이 유형의 최대 페이지 수를 제어합니다. 이는 “이러한 페이지를 최대 3개까지 허용”해야 하거나 단일 페이지에 유용합니다.

max_count_per_parent

단일 부모 페이지 아래에서 생성할 수 있는 이 유형의 최대 페이지 수를 제어합니다.

private_page_options

페이지 유형에 사용할 수 있는 개인 정보 옵션을 제어합니다.

다음 옵션을 사용할 수 있습니다.

  • 'password' - 공유 암호를 사용하여 제한할 수 있습니다.

  • 'groups' - 특정 그룹의 사용자로 제한할 수 있습니다.

  • 'login' - 로그인한 사용자로 제한할 수 있습니다.

class BreadPage(Page):
    ...

    # 기본값
    private_page_options = ['password', 'groups', 'login']

    # 공유 암호 비활성화
    private_page_options = ['groups', 'login']

    # 공유 암호만
    private_page_options = ['password']

    # 이 페이지 모델에 대한 개인 정보 옵션 없음
    private_page_options = []
exclude_fields_in_copy

페이지가 복사될 때 포함되지 않을 필드 이름 배열입니다. ClusterableModel 을 사용하지 않거나 복사해서는 안 되는 관계가 있는 경우 유용합니다.

class BlogPage(Page):
    exclude_fields_in_copy = ['special_relation', 'custom_uuid']

다음 필드는 복사 시 항상 제외됩니다. - ['id', 'path', 'depth', 'numchild', 'url_path', 'path'].

base_form_class

이 유형의 페이지를 Wagtail 페이지 편집기에서 편집하는 데 기본으로 사용되는 폼 클래스입니다. 이 속성은 모델에 설정하여 페이지 편집기 폼을 사용자 지정할 수 있습니다. 폼은 WagtailAdminPageForm 의 서브클래스여야 합니다. 자세한 내용은 생성된 양식 사용자 정의 를 참조하십시오.

with_content_json(content)

Returns a new version of the page with field values updated to reflect changes in the provided content (which usually comes from a previously-saved page revision).

Certain field values are preserved in order to prevent errors if the returned page is saved, such as id, content_type and some tree-related values. The following field values are also preserved, as they are considered to be meaningful to the page as a whole, rather than to a specific revision:

  • draft_title

  • live

  • has_unpublished_changes

  • owner

  • locked

  • locked_by

  • locked_at

  • latest_revision

  • latest_revision_created_at

  • first_published_at

  • alias_of

  • wagtail_admin_comments (COMMENTS_RELATION_NAME)

save(clean=True, user=None, log_action=False, **kwargs)

Writes the page to the database, performing additional housekeeping tasks to ensure data integrity:

  • locale, draft_title and slug are set to default values if not provided, with slug being generated from the title with a suffix to ensure uniqueness within the parent page where necessary

  • The url_path field is set based on the slug and the parent page

  • If the slug has changed, the url_path of this page and all descendants is updated and a page_slug_changed signal is sent

New pages should be saved by passing the unsaved page instance to the add_child() or add_sibling() method of an existing page, which will correctly update the fields responsible for tracking the page’s location in the tree.

If clean=False is passed, the page is saved without validation. This is appropriate for updates that only change metadata such as latest_revision while keeping content and page location unchanged.

If clean=True is passed (the default), and the page has live=True set, the page is validated using full_clean() before saving.

If clean=True is passed, and the page has live=False set, only the title and slug fields are validated.

버전 7.0에서 변경: clean=True now only performs full validation when the page is live. When the page is not live, only the title and slug fields are validated. Previously, full validation was always performed.

copy(recursive=False, to=None, update_attrs=None, copy_revisions=True, keep_live=True, user=None, process_child_object=None, exclude_fields=None, log_action='wagtail.copy', reset_translation_key=True)

Copies a given page

매개변수:

log_action – flag for logging the action. Pass None to skip logging. Can be passed an action string. Defaults to 'wagtail.copy'.

move(new_parent, pos=None)

페이지와 모든 하위 페이지를 새 부모로 이동합니다. 자세한 내용은 django-treebeard 를 참조하십시오.

create_alias(*, recursive=False, parent=None, update_slug=None, update_locale=None, user=None, log_action='wagtail.create_alias', reset_translation_key=True, _mpnode_attrs=None)
update_aliases(*, revision=None, _content=None, _updated_ids=None)

Publishes all aliases that follow this page with the latest content from this page.

This is called by Wagtail whenever a page with aliases is published.

매개변수:

revision (Revision, Optional) – The revision of the original page that we are updating to (used for logging purposes)

get_cache_key_components()

The components of a Page which make up the cache_key. Any change to a page should be reflected in a change to at least one of these components.

cache_key

A generic cache key to identify a page in its current state. Should the page change, so will the key.

Customizations to the cache key should be made in get_cache_key_components.

Site

Site 모델은 서버가 응답하는 각 호스트 이름에 대해 트리의 어떤 부분을 사용할지 관리자가 구성할 수 있도록 하므로 다중 사이트 설치에 유용합니다.

find_for_request() 함수는 주어진 HTTP 요청을 처리할 Site 객체를 반환합니다.

데이터베이스 필드

class wagtail.models.Site
hostname

(텍스트)

스키마, 포트 및 경로를 제외한 사이트의 호스트 이름입니다.

예: www.mysite.com

참고

사이트의 루트 URL을 가져오는 방법을 찾고 있다면 root_url 속성을 사용하십시오.

port

(숫자)

사이트가 응답하는 포트 번호입니다.

site_name

(텍스트 - 선택 사항)

사이트의 사람이 읽을 수 있는 이름입니다. Wagtail 자체에서는 사용되지 않지만, <title> 요소와 같이 사이트 프런트엔드에서 사용하기에 적합합니다.

예: Rod의 세상

root_page

(Page 에 대한 외래 키)

사이트의 루트 페이지에 대한 링크입니다. 이 페이지는 사이트의 / URL에 나타나는 페이지이며 일반적으로 홈페이지입니다.

is_default_site

(부울)

사이트가 기본값인 경우 True 로 설정됩니다. 하나의 사이트만 기본값이 될 수 있습니다.

기본 사이트는 필요한 호스트 이름/포트를 가진 사이트를 찾을 수 없는 경우 대체로 사용됩니다.

메서드 및 속성

class wagtail.models.Site
static find_for_request(request)

Find the site object responsible for responding to this HTTP request object. Try:

  • unique hostname first

  • then hostname and port

  • if there is no matching hostname at all, or no matching hostname:port combination, fall back to the unique default site, or raise an exception

NB this means that high-numbered ports on an extant hostname may still be routed to a different hostname which is set as the default

The site will be cached via request._wagtail_site

root_url

이것은 사이트의 URL을 반환합니다. hostnameport 필드에서 계산됩니다.

URL의 스키마 부분은 port 필드의 값에 따라 계산됩니다.

  • 80 = http://

  • 443 = https://

  • 다른 모든 것은 http:// 스키마를 사용하며 포트는 호스트 이름 끝에 추가됩니다(예: http://mysite.com:8000/)

static get_site_root_paths()

Return a list of SiteRootPath instances, most specific path first - used to translate url_paths into actual URLs with hostnames.

Each root path is an instance of the SiteRootPath named tuple, and have the following attributes:

  • site_id - The ID of the Site record

  • root_path - The internal URL path of the site’s home page (for example ‘/home/’)

  • root_url - The scheme/domain name of the site (for example ‘https://www.example.com/’)

  • language_code - The language code of the site (for example ‘en’)

Locale

Locale 모델은 사이트에서 사용할 수 있는 언어 및/또는 로케일 세트를 정의합니다. 각 Locale 레코드는 WAGTAIL_CONTENT_LANGUAGES 설정에 정의된 “언어 코드”에 해당합니다.

Wagtail은 처음에 모든 기존 콘텐츠에 대한 기본 언어로 하나의 Locale 을 설정합니다. 이 첫 번째 로케일은 LANGUAGE_CODE 에 정의된 사이트 기본 언어 코드와 가장 일치하는 WAGTAIL_CONTENT_LANGUAGES 의 값을 자동으로 선택합니다. 기본 언어 코드가 나중에 변경되면 Wagtail은 새 Locale 레코드를 자동으로 만들거나 기존 레코드를 업데이트하지 않습니다.

국제화가 활성화되기 전에 모든 페이지는 이 기본 Locale 레코드를 사용합니다. 이는 데이터베이스 제약 조건을 충족하고 나중에 국제화를 더 쉽게 켤 수 있도록 하기 위함입니다.

WAGTAIL_CONTENT_LANGUAGES 변경

WAGTAIL_CONTENT_LANGUAGES 에서 언어를 추가하거나 제거할 수 있습니다.

WAGTAIL_CONTENT_LANGUAGES 에서 옵션을 제거하기 전에 Locale 레코드를 다른 콘텐츠 언어를 사용하도록 업데이트하거나 삭제하는 것이 중요합니다. 유효하지 않은 콘텐츠 언어를 가진 Locale 인스턴스는 모든 데이터베이스 쿼리에서 자동으로 필터링되어 편집하거나 볼 수 없게 됩니다.

메서드 및 속성

class wagtail.models.Locale
language_code

The language code that represents this locale

The language code can either be a language code on its own (such as en, fr), or it can include a region code (such as en-gb, fr-fr).

classmethod get_default()

Returns the default Locale based on the site’s LANGUAGE_CODE setting.

classmethod get_active()

Returns the Locale that corresponds to the currently activated language in Django.

language_name

Uses data from django.conf.locale to return the language name in English. For example, if the object’s language_code were "fr", the return value would be "French".

Raises KeyError if django.conf.locale has no information for the object’s language_code value.

language_name_local

Uses data from django.conf.locale to return the language name in the language itself. For example, if the language_code were "fr" (French), the return value would be "français".

Raises KeyError if django.conf.locale has no information for the object’s language_code value.

language_name_localized

Uses data from django.conf.locale to return the language name in the currently active language. For example, if language_code were "fr" (French), and the active language were "da" (Danish), the return value would be "Fransk".

Raises KeyError if django.conf.locale has no information for the object’s language_code value.

is_default

Returns a boolean indicating whether this object is the default locale.

is_active

Returns a boolean indicating whether this object is the currently active locale.

is_bidi

Returns a boolean indicating whether the language is bi-directional.

get_display_name() str

TranslatableMixin

TranslatableMixin 은 번역 가능하도록 모든 비페이지 Django 모델에 추가할 수 있는 추상 모델입니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다.

관리자에서 비페이지 모델을 번역 가능하게 하려면 스니펫으로 등록해야 합니다. 번역 가능한 스니펫도 참조하십시오.

데이터베이스 필드

class wagtail.models.TranslatableMixin
locale

(wagtail.models.Locale 에 대한 외래 키)

페이지의 경우 부모 페이지의 로케일로 기본 설정됩니다.

translation_key

(uuid)

새 모델 인스턴스가 생성될 때마다 무작위로 생성되는 UUID입니다. 이는 해당 인스턴스의 모든 번역과 공유되므로 번역을 쿼리하는 데 사용할 수 있습니다.

translation_keylocale 필드에는 객체가 한 언어로 두 번 이상 번역되는 것을 방지하기 위한 고유 키 제약 조건이 있습니다.

참고

이는 현재 TranslatableMixin.Metaunique_together 를 통해 강제되지만, 향후 TranslatableMixin.Meta.constraintsUniqueConstraint 로 대체될 수 있습니다.

모델이 Meta 클래스를 정의하는 경우(새 정의 또는 TranslatableMixin.Meta 를 명시적으로 상속하는 경우), unique_together 또는 constraints 를 설정할 때 주의하십시오. translation_keylocaleunique_together 또는 UniqueConstraint(둘 다 아님)가 있는지 확인하십시오. 이에 대한 시스템 검사가 있습니다.

메서드 및 속성

class wagtail.models.TranslatableMixin
get_translations(inclusive=False)

Returns a queryset containing the translations of this instance.

get_translation(locale)

Finds the translation in the specified locale.

If there is no translation in that locale, this raises a model.DoesNotExist exception.

get_translation_or_none(locale)

Finds the translation in the specified locale.

If there is no translation in that locale, this returns None.

has_translation(locale)

Returns True if a translation exists in the specified locale.

copy_for_translation(locale, exclude_fields=None)

Creates a copy of this instance with the specified locale.

Note that the copy is initially unsaved.

classmethod get_translation_model()

Returns this model’s “Translation model”.

The “Translation model” is the model that has the locale and translation_key fields. Typically this would be the current model, but it may be a super-class if multi-table inheritance is in use (as is the case for wagtailcore.Page).

localized

Finds the translation in the current active language.

If there is no translation in the active language, self is returned.

Note: This will not return the translation if it is in draft. If you want to include drafts, use the .localized_draft attribute instead.

PreviewableMixin

PreviewableMixin 은 인스턴스를 미리 볼 수 있도록 모든 비페이지 Django 모델에 추가할 수 있는 믹스인 클래스입니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다.

관리자에서 비페이지 모델을 미리 볼 수 있게 하려면 스니펫으로 등록해야 합니다. 스니펫 미리 보기 가능하게 만들기도 참조하십시오.

메서드 및 속성

class wagtail.models.PreviewableMixin
preview_modes

A list of (internal_name, display_name) tuples for the modes in which this object can be displayed for preview/moderation purposes. Ordinarily an object will only have one display mode, but subclasses can override this - for example, a page containing a form might have a default view of the form, and a post-submission ‘thank you’ page. Set to [] to completely disable previewing for this model.

default_preview_mode

The default preview mode to use in live preview. This default is also used in areas that do not give the user the option of selecting a mode explicitly, e.g. in the moderator approval workflow. If preview_modes is empty, an IndexError will be raised.

preview_sizes

A list of dictionaries, each representing a preview size option for this object. Override this property to customize the preview sizes. Each dictionary in the list should include the following keys:

  • name: A string representing the internal name of the preview size.

  • icon: A string specifying the icon’s name for the preview size button.

  • device_width: An integer indicating the device’s width in pixels.

  • label: A string for the aria label on the preview size button.

@property
def preview_sizes(self):
    return [
        {
            "name": "mobile",
            "icon": "mobile-icon",
            "device_width": 320,
            "label": "Preview in mobile size"
        },
        # Add more preview size dictionaries as needed.
    ]
default_preview_size

The default preview size name to use in live preview. Defaults to "mobile", which is the first one defined in preview_sizes. If preview_sizes is empty, an IndexError will be raised.

is_previewable()

Returns True if at least one preview mode is specified in preview_modes.

get_preview_context(request, mode_name)

Returns a context dictionary for use in templates for previewing this object.

get_preview_template(request, mode_name)

Returns a template to be used when previewing this object.

Subclasses of PreviewableMixin must override this method to return the template name to be used in the preview. Alternatively, subclasses can also override the serve_preview method to completely customise the preview rendering logic.

serve_preview(request, mode_name)

Returns an HTTP response for use in object previews.

This method can be overridden to implement custom rendering and/or routing logic.

Any templates rendered during this process should use the request object passed here - this ensures that request.user and other properties are set appropriately for the wagtail user bar to be displayed/hidden. This request will always be a GET.

RevisionMixin

RevisionMixin 은 인스턴스의 개정을 저장할 수 있도록 모든 비페이지 Django 모델에 추가할 수 있는 추상 모델입니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다.

관리자에서 비페이지 모델을 개정 가능하게 하려면 스니펫으로 등록해야 합니다. 스니펫 개정 저장도 참조하십시오.

데이터베이스 필드

class wagtail.models.RevisionMixin
latest_revision

(Revision 에 대한 외래 키)

이것은 객체에 대해 생성된 최신 개정을 가리킵니다. 이 참조는 성능 최적화를 위해 데이터베이스에 저장됩니다.

메서드 및 속성

class wagtail.models.RevisionMixin
_revisions

A default GenericRelation for the purpose of automatically deleting revisions when the object is deleted. This is not used to query the object’s revisions. Instead, the revisions() property is used for that purpose. As such, this default relation is considered private.

This GenericRelation does not have a related_query_name, so it cannot be used for reverse-related queries from Revision back to this model. If the feature is desired, subclasses can define their own GenericRelation to Revision with a custom related_query_name.

Added in version 7.1: The default GenericRelation _revisions was added.

revisions

Returns revisions that belong to the object. For non-page models, this is done by querying the Revision model directly rather than using a GenericRelation, to avoid a known limitation in Django for models with multi-table inheritance where the relation’s content type may not match the instance’s type.

save_revision(user=None, approved_go_live_at=None, changed=True, log_action=False, previous_revision=None, clean=True)

Creates and saves a revision.

매개변수:
  • user – The user performing the action.

  • approved_go_live_at – The date and time the revision is approved to go live.

  • changed – Indicates whether there were any content changes.

  • log_action – Flag for logging the action. Pass True to also create a log entry. Can be passed an action string. Defaults to "wagtail.edit" when no previous_revision param is passed, otherwise "wagtail.revert".

  • previous_revision (Revision) – Indicates a revision reversal. Should be set to the previous revision instance.

  • clean – Set this to False to skip cleaning object content before saving this revision.

반환:

The newly created revision.

get_latest_revision_as_object()

Returns the latest revision of the object as an instance of the model. If no latest revision exists, returns the object itself.

with_content_json(content)

Returns a new version of the object with field values updated to reflect changes in the provided content (which usually comes from a previously-saved revision).

Certain field values are preserved in order to prevent errors if the returned object is saved, such as id. The following field values are also preserved, as they are considered to be meaningful to the object as a whole, rather than to a specific revision:

  • latest_revision

If TranslatableMixin is applied, the following field values are also preserved:

  • translation_key

  • locale

DraftStateMixin

DraftStateMixin 은 인스턴스에 게시되지 않은 변경 사항을 허용하도록 모든 비페이지 Django 모델에 추가할 수 있는 추상 모델입니다. 이 믹스인은 RevisionMixin 이 적용되어야 합니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다.

관리자에서 비페이지 모델에 게시 기능이 있도록 하려면 스니펫으로 등록해야 합니다. 스니펫 초안 변경 사항 저장도 참조하십시오.

데이터베이스 필드

class wagtail.models.DraftStateMixin
live

(부울)

객체가 게시된 경우 True 로 설정되는 부울입니다.

참고: 이 필드는 기본적으로 True 로 설정되어 프로그래밍 방식으로 생성된 모든 객체가 기본적으로 게시됩니다.

live_revision

(Revision 에 대한 외래 키)

이것은 현재 라이브 상태인 개정을 가리킵니다.

has_unpublished_changes

(부울)

객체가 초안이거나 초안 변경 사항과 함께 게시된 경우 True 로 설정되는 부울입니다.

first_published_at

(날짜/시간)

객체가 처음 게시된 날짜/시간입니다.

last_published_at

(날짜/시간)

객체가 마지막으로 게시된 날짜/시간입니다.

메서드 및 속성

class wagtail.models.DraftStateMixin
publish(revision, user=None, changed=True, log_action=True, previous_revision=None, skip_permission_checks=False)

Publish a revision of the object by applying the changes in the revision to the live object.

매개변수:
  • revision (Revision) – Revision to publish.

  • user – The publishing user.

  • changed – Indicated whether content has changed.

  • log_action – Flag for the logging action, pass False to skip logging.

  • previous_revision (Revision) – Indicates a revision reversal. Should be set to the previous revision instance.

unpublish(set_expired=False, commit=True, user=None, log_action=True)

Unpublish the live object.

매개변수:
  • set_expired – Mark the object as expired.

  • commit – Commit the changes to the database.

  • user – The unpublishing user.

  • log_action – Flag for the logging action, pass False to skip logging.

with_content_json(content)

Similar to RevisionMixin.with_content_json(), but with the following fields also preserved:

  • live

  • has_unpublished_changes

  • first_published_at

LockableMixin

LockableMixin 은 인스턴스를 잠글 수 있도록 모든 비페이지 Django 모델에 추가할 수 있는 추상 모델입니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다. 자세한 내용은 스니펫 잠금를 참조하십시오.

관리자에서 비페이지 모델을 잠금 가능하게 하려면 스니펫으로 등록해야 합니다. 스니펫 잠금도 참조하십시오.

데이터베이스 필드

class wagtail.models.LockableMixin
locked

(부울)

객체가 잠긴 경우 True 로 설정되는 부울입니다.

locked_at

(날짜/시간)

객체가 잠긴 날짜/시간입니다.

locked_by

(사용자 모델에 대한 외래 키)

객체를 잠근 사용자입니다.

메서드 및 속성

class wagtail.models.LockableMixin
get_lock()

Returns a sub-class of BaseLock if the instance is locked, otherwise None.

with_content_json(content)

Similar to RevisionMixin.with_content_json(), but with the following fields also preserved:

  • locked

  • locked_at

  • locked_by

WorkflowMixin

WorkflowMixin 은 인스턴스를 워크플로에 제출할 수 있도록 모든 비페이지 Django 모델에 추가할 수 있는 믹스인 클래스입니다. 이 믹스인은 RevisionMixinDraftStateMixin 이 적용되어야 합니다. 페이지에는 이미 이 믹스인이 포함되어 있으므로 추가할 필요가 없습니다. 자세한 내용은 스니펫에 워크플로 활성화를 참조하십시오.

관리자에서 비페이지 모델에 워크플로 기능이 있도록 하려면 스니펫으로 등록해야 합니다. 스니펫에 워크플로 활성화도 참조하십시오.

메서드 및 속성

class wagtail.models.WorkflowMixin
classmethod get_default_workflow()

Returns the active workflow assigned to the model.

For non-Page models, workflows are assigned to the model’s content type, thus shared across all instances instead of being assigned to individual instances (unless get_workflow() is overridden).

This method is used to determine the workflow to use when creating new instances of the model. On Page models, this method is unused as the workflow can be determined from the parent page’s workflow.

has_workflow

Returns `True` if the object has an active workflow assigned, otherwise `False`.

get_workflow()

Returns the active workflow assigned to the object.

_workflow_states

A default GenericRelation for the purpose of automatically deleting workflow states when the object is deleted. This is not used to query the object’s workflow states. Instead, the workflow_states() property is used for that purpose. As such, this default relation is considered private.

This GenericRelation does not have a related_query_name, so it cannot be used for reverse-related queries from WorkflowState back to this model. If the feature is desired, subclasses can define their own GenericRelation to WorkflowState with a custom related_query_name.

Added in version 7.1: The default GenericRelation _workflow_states was added.

workflow_states

Returns workflow states that belong to the object. For non-page models, this is done by querying the WorkflowState model directly rather than using a GenericRelation, to avoid a known limitation in Django for models with multi-table inheritance where the relation’s content type may not match the instance’s type.

workflow_in_progress

Returns `True` if a workflow is in progress on the current object, otherwise `False`.

current_workflow_state

Returns the in progress or needs changes workflow state on this object, if it exists.

current_workflow_task_state

Returns (specific class of) the current task state of the workflow on this object, if it exists.

current_workflow_task

Returns (specific class of) the current task in progress on this object, if it exists.

Revision

페이지가 편집될 때마다 새 Revision 이 생성되어 데이터베이스에 저장됩니다. 이는 페이지에 대한 모든 변경 사항의 전체 기록을 찾는 데 사용할 수 있으며, 새 변경 사항이 라이브로 전환되기 전에 보관할 장소도 제공합니다.

  • 개정은 RevisionMixin 의 인스턴스에서 save_revision() 메서드를 호출하여 생성할 수 있습니다.

  • 페이지의 내용은 JSON 직렬화 가능하며 content 필드에 저장됩니다.

  • as_object() 메서드를 호출하여 객체의 모델 인스턴스로 Revision 을 검색할 수 있습니다.

더 이상 사용되지 않는 오래된 개정을 삭제하려면 purge_revisions 명령을 사용할 수 있습니다.

데이터베이스 필드

class wagtail.models.Revision
content_object

(제네릭 외래 키)

이 개정이 속한 객체입니다. 페이지 개정의 경우 객체는 특정 클래스의 인스턴스입니다.

content_type

(ContentType 에 대한 외래 키)

이 개정이 속한 객체의 콘텐츠 유형입니다. 페이지 개정의 경우 특정 페이지 유형의 콘텐츠 유형을 의미합니다.

base_content_type

(ContentType 에 대한 외래 키)

이 개정이 속한 객체의 기본 콘텐츠 유형입니다. 페이지 개정의 경우 Page 모델의 콘텐츠 유형을 의미합니다.

object_id

(문자열)

이 개정이 속한 객체의 기본 키입니다.

created_at

(날짜/시간)

개정이 생성된 시간입니다.

user

(사용자 모델에 대한 외래 키)

개정을 만든 사용자입니다.

content

(사전)

개정이 생성될 당시 객체의 JSON 콘텐츠입니다.

관리자

class wagtail.models.Revision
objects

이 기본 관리자는 데이터베이스의 모든 Revision 객체를 검색하는 데 사용됩니다. 또한 특정 객체의 개정을 쿼리할 수 있는 wagtail.models.RevisionsManager.for_instance 메서드를 제공합니다.

예시:

Revision.objects.all()
Revision.objects.for_instance(my_object)
page_revisions

이 관리자는 기본 관리자를 확장하며 페이지에 속하는 모든 Revision 객체를 검색하는 데 사용됩니다.

예시:

Revision.page_revisions.all()

메서드 및 속성

class wagtail.models.Revision
as_object()

이 메서드는 이 개정을 객체의 특정 클래스 인스턴스로 검색합니다. 개정이 페이지에 속하는 경우 Page 의 특정 서브클래스 인스턴스가 됩니다.

is_latest_revision()

이 개정이 객체의 최신 개정인 경우 True 를 반환합니다.

publish(user=None, changed=True, log_action=True, previous_revision=None, skip_permission_checks=False)

이것을 호출하면 이 개정의 내용이 라이브 객체로 복사됩니다. 객체가 초안인 경우 게시됩니다.

base_content_object

이 속성은 이 개정이 속한 객체를 기본 클래스의 인스턴스로 반환합니다.

GroupPagePermission

데이터베이스 필드

class wagtail.models.GroupPagePermission
group

(django.contrib.auth.models.Group 에 대한 외래 키)

page

(Page 에 대한 외래 키)

PageViewRestriction

데이터베이스 필드

class wagtail.models.PageViewRestriction
page

(Page 에 대한 외래 키)

password

(텍스트)

restriction_type

(텍스트)

옵션: none, password, groups, login

Orderable (추상)

데이터베이스 필드

class wagtail.models.Orderable
sort_order

(숫자)

Workflow

워크플로는 작업이 객체에 대해 수행되려면(일반적으로 게시) 승인되어야 하는 작업 시퀀스를 나타냅니다.

데이터베이스 필드

class wagtail.models.Workflow
name

(텍스트)

워크플로의 사람이 읽을 수 있는 이름입니다.

active

(부울)

워크플로가 활성 상태인지 여부: 활성 워크플로는 워크플로에 추가하고 시작할 수 있습니다. 비활성 워크플로는 추가할 수 없으며, 기존 워크플로에 있는 경우 건너뜁니다.

메서드 및 속성

class wagtail.models.Workflow
start(obj, user)

Initiates a workflow by creating an instance of WorkflowState.

tasks

Returns all Task instances linked to this workflow.

deactivate(user=None)

Sets the workflow as inactive, and cancels all in progress instances of WorkflowState linked to this workflow.

all_pages()

Returns a queryset of all the pages that this Workflow applies to.

WorkflowState

워크플로 상태는 객체에서 시작된 워크플로의 상태를 나타냅니다.

데이터베이스 필드

class wagtail.models.WorkflowState
content_object

(제네릭 외래 키)

워크플로가 시작된 객체입니다. 페이지 워크플로의 경우 객체는 기본 Page 모델의 인스턴스입니다.

content_type

(ContentType 에 대한 외래 키)

이 워크플로 상태가 속한 객체의 콘텐츠 유형입니다. 페이지 워크플로의 경우 특정 페이지 유형의 콘텐츠 유형을 의미합니다.

base_content_type

(ContentType 에 대한 외래 키)

이 워크플로 상태가 속한 객체의 기본 콘텐츠 유형입니다. 페이지 워크플로의 경우 Page 모델의 콘텐츠 유형을 의미합니다.

object_id

(문자열)

이 개정이 속한 객체의 기본 키입니다.

workflow

(Workflow 에 대한 외래 키)

WorkflowState 가 나타내는 상태인 워크플로입니다.

status

(텍스트)

워크플로의 현재 상태(옵션은 TaskState.STATUS_CHOICES)입니다.

created_at

(날짜/시간)

WorkflowState 인스턴스가 생성된 시점 - 워크플로가 시작된 시점

requested_by

(사용자 모델에 대한 외래 키)

이 워크플로를 시작한 사용자입니다.

current_task_state

(TaskState 에 대한 외래 키)

워크플로가 현재 있는 작업에 대한 TaskState 모델: 완료 중(진행 중인 경우) 또는 최종 작업 상태(완료된 경우)

메서드 및 속성

class wagtail.models.WorkflowState
STATUS_CHOICES

status 필드에 대한 가능한 옵션과 해당 상세 이름의 튜플입니다. 옵션은 STATUS_IN_PROGRESS, STATUS_APPROVED, STATUS_CANCELLED, STATUS_REJECTEDSTATUS_SKIPPED 입니다.

update(user=None, next_task=None)

Checks the status of the current task, and progresses (or ends) the workflow if appropriate. If the workflow progresses, next_task will be used to start a specific task next if provided.

get_next_task()

Returns the next active task, which has not been either approved or skipped.

cancel(user=None)

Cancels the workflow state

finish(user=None)

Finishes a successful in progress workflow, marking it as approved and performing the on_finish action.

resume(user=None)

Put a STATUS_NEEDS_CHANGES workflow state back into STATUS_IN_PROGRESS, and restart the current task

copy_approved_task_states_to_revision(revision)

Creates copies of previously approved task states with revision set to a different revision.

all_tasks_with_status()

Returns a list of Task objects that are linked with this workflow state’s workflow. The status of that task in this workflow state is annotated in the .status field. And a displayable version of that status is annotated in the .status_display field.

This is different to querying TaskState as it also returns tasks that haven’t been started yet (so won’t have a TaskState).

revisions()

Returns all revisions associated with task states linked to the current workflow state.

Task

작업은 워크플로가 성공적으로 완료되려면 승인되어야 하는 워크플로의 단계를 나타냅니다.

데이터베이스 필드

class wagtail.models.Task
name

(텍스트)

작업의 사람이 읽을 수 있는 이름입니다.

active

(부울)

작업이 활성 상태인지 여부: 활성 워크플로는 워크플로에 추가하고 시작할 수 있습니다. 비활성 워크플로는 추가할 수 없으며, 기존 워크플로에 있는 경우 건너뜁니다.

content_type

(ContentType 에 대한 외래 키)

이 작업의 특정 모델을 나타내는 ContentType 객체에 대한 외래 키입니다.

메서드 및 속성

class wagtail.models.Task
workflows

Returns all Workflow instances that use this task.

active_workflows

Return a QuerySet` of active workflows that this task is part of.

task_state_class

이 작업에 대한 상태 정보를 저장하기 위해 생성할 특정 작업 상태 클래스입니다. 지정되지 않은 경우 TaskState 가 됩니다.

classmethod get_verbose_name()

Returns the human-readable “verbose name” of this task model e.g “Group approval task”.

specific

Returns this object in its most specific subclassed form with all field values fetched from the database. The result is cached in memory.

start(workflow_state, user=None)

Start this task on the provided workflow state by creating an instance of TaskState.

on_action(task_state, user, action_name, **kwargs)

Performs an action on a task state determined by the action_name string passed.

user_can_access_editor(obj, user)

Returns True if a user who would not normally be able to access the editor for the object should be able to if the object is currently on this task. Note that returning False does not remove permissions from users who would otherwise have them.

user_can_lock(obj, user)

Returns True if a user who would not normally be able to lock the object should be able to if the object is currently on this task. Note that returning False does not remove permissions from users who would otherwise have them.

user_can_unlock(obj, user)

Returns True if a user who would not normally be able to unlock the object should be able to if the object is currently on this task. Note that returning False does not remove permissions from users who would otherwise have them.

locked_for_user(obj, user)

Returns True if the object should be locked to a given user’s edits. This can be used to prevent editing by non-reviewers.

get_actions(obj, user)

Get the list of action strings (name, verbose_name, whether the action requires additional data - see get_form_for_action) for actions the current user can perform for this task on the given object. These strings should be the same as those able to be passed to on_action.

get_task_states_user_can_moderate(user, **kwargs)

Returns a QuerySet of the task states the current user can moderate

deactivate(user=None)

Set active to False and cancel all in progress task states linked to this task.

get_form_for_action(action)
get_template_for_action(action)

Specifies a template for the workflow action modal.

classmethod get_description()

Returns the task description.

TaskState

작업 상태는 특정 개정에서 작업 진행 상황에 대한 상태 정보를 저장합니다.

데이터베이스 필드

class wagtail.models.TaskState
workflow_state

(WorkflowState 에 대한 외래 키)

이 작업 상태를 시작한 워크플로 상태입니다.

revision

(Revision 에 대한 외래 키)

이 작업 상태가 생성된 개정입니다.

task

(Task 에 대한 외래 키)

이 작업 상태가 상태 정보를 저장하는 작업입니다.

status

(텍스트)

이 개정에서 작업의 완료 상태입니다. 옵션은 TaskState.STATUS_CHOICES 에서 사용할 수 있습니다.

content_type

(ContentType 에 대한 외래 키)

이 작업의 특정 모델을 나타내는 ContentType 객체에 대한 외래 키입니다.

started_at

(날짜/시간)

이 작업 상태가 생성된 시점입니다.

finished_at

(날짜/시간)

이 작업 상태가 취소, 거부 또는 승인된 시점입니다.

finished_by

(사용자 모델에 대한 외래 키)

작업을 완료(취소, 거부, 승인)한 사용자입니다.

comment

(텍스트)

작업이 완료될 때 사용자가 일반적으로 추가하는 텍스트 주석입니다.

메서드 및 속성

class wagtail.models.TaskState
STATUS_CHOICES

status 필드에 대한 가능한 옵션과 해당 상세 이름의 튜플입니다. 옵션은 STATUS_IN_PROGRESS, STATUS_APPROVED, STATUS_CANCELLED, STATUS_REJECTEDSTATUS_SKIPPED 입니다.

exclude_fields_in_copy

TaskState.copy() 메서드가 호출될 때 복사되지 않을 필드 목록입니다.

specific

Returns this object in its most specific subclassed form with all field values fetched from the database. The result is cached in memory.

approve(user=None, update=True, comment='')

Approve the task state and update the workflow state.

reject(user=None, update=True, comment='')

Reject the task state and update the workflow state.

task_type_started_at

Finds the first chronological started_at for successive TaskStates - ie started_at if the task had not been restarted.

cancel(user=None, resume=False, comment='')

Cancel the task state and update the workflow state. If resume is set to True, then upon update the workflow state is passed the current task as next_task, causing it to start a new task state on the current task if possible.

copy(update_attrs=None, exclude_fields=None)

Copy this task state, excluding the attributes in the exclude_fields list and updating any attributes to values specified in the update_attrs dictionary of attribute: new value pairs.

get_comment()

Returns a string that is displayed in workflow history.

This could be a comment by the reviewer, or generated. Use mark_safe to return HTML.

WorkflowTask

특정 워크플로에서 작업의 순서를 나타냅니다.

데이터베이스 필드

class wagtail.models.WorkflowTask
workflow

(Workflow 에 대한 외래 키)

task

(Task 에 대한 외래 키)

sort_order

(숫자)

워크플로에서 작업의 순서입니다.

WorkflowPage

워크플로를 페이지 및 해당 하위 페이지에 할당하는 것을 나타냅니다.

데이터베이스 필드

class wagtail.models.WorkflowPage
workflow

(Workflow 에 대한 외래 키)

page

(Page 에 대한 외래 키)

WorkflowContentType

워크플로를 Django 모델에 할당하는 것을 나타냅니다.

데이터베이스 필드

class wagtail.models.WorkflowContentType
workflow

(Workflow 에 대한 외래 키)

content_type

(ContentType 에 대한 외래 키)

워크플로에 할당된 모델을 나타내는 ContentType 객체에 대한 외래 키입니다.

BaseLogEntry

객체에 대해 수행된 작업 기록을 나타내는 추상 기본 클래스입니다.

데이터베이스 필드

class wagtail.models.BaseLogEntry
content_type

(ContentType 에 대한 외래 키)

이 모델의 특정 모델을 나타내는 ContentType 객체에 대한 외래 키입니다.

label

(텍스트)

항목 생성 시 객체 제목

참고: Wagtail은 LogEntryManager.log_action 에 전달된 객체의 get_admin_display_title 또는 문자열 표현을 사용하려고 시도합니다.

user

(사용자 모델에 대한 외래 키)

작업을 트리거한 사용자에 대한 외래 키입니다.

revision

(Revision 에 대한 외래 키)

현재 개정에 대한 외래 키입니다.

data

(사전)

각 작업에 대한 추가 세부 정보의 JSON 표현입니다. 예를 들어, 페이지에서 복사할 때 원본 페이지 ID 및 제목. 또는 워크플로 전환 시 워크플로 ID/이름 및 다음 단계 ID/이름

timestamp

(날짜/시간)

항목이 생성된 날짜/시간입니다.

content_changed

(부울)

콘텐츠가 변경된 경우 True 로 설정할 수 있는 부울입니다.

deleted

(부울)

객체가 삭제된 경우 True 로 설정할 수 있는 부울입니다. 사이트 기록 보고서에서 항목을 필터링하는 데 사용됩니다.

메서드 및 속성

class wagtail.models.BaseLogEntry
user_display_name

Returns the display name of the associated user; get_full_name if available and non-empty, otherwise get_username. Defaults to ‘system’ when none is provided

comment
object_verbose_name
object_id()

PageLogEntry

Page 에 대해 수행된 작업 기록을 나타내며, BaseLogEntry 를 서브클래스합니다.

데이터베이스 필드

class wagtail.models.PageLogEntry
page

(Page 에 대한 외래 키)

작업이 수행되는 페이지에 대한 외래 키입니다.

Comment

페이지에 대한 주석을 나타냅니다.

데이터베이스 필드

class wagtail.models.Comment
page

(Page 에 대한 부모 키)

주석이 추가된 페이지에 대한 부모 키입니다.

user

(사용자 모델에 대한 외래 키)

이 주석을 추가한 사용자에 대한 외래 키입니다.

text

(텍스트)

주석의 텍스트 내용입니다.

contentpath

(텍스트)

주석이 첨부된 필드 또는 스트림필드 블록의 경로로, field 또는 field.streamfield_block_id 형식입니다.

position

(텍스트)

필드 내 주석 위치에 대한 식별자입니다. 사용되는 형식은 필드에 따라 결정됩니다.

created_at

(날짜/시간)

주석이 생성된 날짜/시간입니다.

updated_at

(날짜/시간)

주석이 업데이트된 날짜/시간입니다.

revision_created

(Revision 에 대한 외래 키)

주석이 생성된 개정에 대한 외래 키입니다.

resolved_at

(날짜/시간)

주석이 해결된 날짜/시간(있는 경우)입니다.

resolved_by

(사용자 모델에 대한 외래 키)

이 주석을 해결한 사용자(있는 경우)에 대한 외래 키입니다.

CommentReply

주석 스레드에 대한 답글을 나타냅니다.

데이터베이스 필드

class wagtail.models.CommentReply
comment

(Comment 에 대한 부모 키)

스레드를 시작한 주석에 대한 부모 키입니다.

user

(사용자 모델에 대한 외래 키)

이 주석을 추가한 사용자에 대한 외래 키입니다.

text

(텍스트)

주석의 텍스트 내용입니다.

created_at

(날짜/시간)

주석이 생성된 날짜/시간입니다.

updated_at

(날짜/시간)

주석이 업데이트된 날짜/시간입니다.

PageSubscription

페이지 이벤트에 대한 이메일 알림 구독을 나타냅니다. 현재 주석 알림에만 사용됩니다.

데이터베이스 필드

class wagtail.models.PageSubscription
page

(Page 에 대한 부모 키)

user

(사용자 모델에 대한 외래 키)

comment_notifications

(부울)

사용자가 모든 주석에 대한 알림을 받아야 하는지, 아니면 참여하는 스레드의 주석에 대해서만 받아야 하는지 여부입니다.