本文整理匯總了Python中mezzanine.pages.models.RichTextPage.in_menus方法的典型用法代碼示例。如果您正苦於以下問題:Python RichTextPage.in_menus方法的具體用法?Python RichTextPage.in_menus怎麽用?Python RichTextPage.in_menus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mezzanine.pages.models.RichTextPage
的用法示例。
在下文中一共展示了RichTextPage.in_menus方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_cms_page
# 需要導入模塊: from mezzanine.pages.models import RichTextPage [as 別名]
# 或者: from mezzanine.pages.models.RichTextPage import in_menus [as 別名]
def update_cms_page(self, title=None, content='', parent_title=None, draft=False):
if not title:
title = 'Untitled'
from mezzanine.pages.models import Page, RichTextPage
page = get_cms_page_from_title(title)
in_menus = [2,3]
# create the page
from mezzanine.core.models import CONTENT_STATUS_PUBLISHED, CONTENT_STATUS_DRAFT
if not page:
parent_page = get_cms_page_from_title(parent_title)
page = RichTextPage(title=title, content_model='richtextpage', parent=parent_page, content=content, status=CONTENT_STATUS_PUBLISHED)
page.save()
page.status = CONTENT_STATUS_DRAFT if draft else CONTENT_STATUS_PUBLISHED
page.in_menus = in_menus
else:
# Can't find an easy way to edit page.richtextpage.content, so let's write directly to the DB!
from django.db import connection
cursor = connection.cursor()
cursor.execute('''update pages_richtextpage set content = %s where page_ptr_id = %s''', [content, page.id])
page.save()
return page