A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://docs.django-cms.org/en/latest/explanation/publishing.html below:

Publishing - django cms 5.1.0dev1 documentation

Toggle table of contents sidebar

Publishing

Without an additional package installed that supports versioning all django CMS pages are published by default. This means they are visible to the public the moment you save them. Accordingly, all changes you make are visible immediately.

djangocms-versioning is a general purpose package that manages versions within different categories, like published, draft, unpublished, or archived. django CMS, however, is not restricted to work with djangocms-versioning. You can use other versioning packages or come up with your own either from scratch or by forking djangocms-versioning.

This section gives a short introduction on how to work with djangocms-versioning. For details please consult the djangocms-versioning documentation.

Also, while this section focuses on pages, djangocms-versioning can lend its versioning capabilities to other objects, too, e.g., aliases as defined in djangocms-alias.

Version states

Each Page object can have many PageContent objects assigned actually containing the page’s content (hence the name) in a specific language. Djangocms-versioning extends this relationship by allowing more PageContent objects to carry a version number and version state. The states are:

Each new draft version will generate a new version number.

When a page is published, it is publicly visible even if its parent pages are not published.

Code and PageContent

When handling PageContent in code, you’ll generally only “see” published pages:

PageContent.objects.filter(language="en")   # get all published English page contents

will only give published pages. This is to ensure that no draft or unpublished versions leaks or become visible to the public.

Since often draft page contents are the ones you interact with in the admin interface, or in draft mode in the CMS frontend, djangocms-versioning introduces an additional model manager for the PageContents which may only be used on admin sites and admin forms:

PageContent.admin_manager.filter(page=my_page, language="en")

will retrieve page content objects of all versions. Alternatively, to get the current draft version you can to filter the Version object:

from djangocms_versioning.constants import DRAFT
from djangocms_versioning.models import Version

version = Version.objects.get(content__page=my_page, content__language="en", status=DRAFT)
draft_content = Version.content

Finally, there are instance where you want to access the “current” version of a page. This is either the current draft version or - there is no draft - the published version. You can easily achieve this by using:

for content in PageContent.admin_manager.filter(page=my_page).current_content():
    # iterates over the current (draft or published) version of all languages of my page
    if content.versions.first().state == DRAFT:
        # do something

For more details see the documentation of djangocms-versioning!


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4