本文整理汇总了Python中feincms.module.page.models.Page.content_type_for方法的典型用法代码示例。如果您正苦于以下问题:Python Page.content_type_for方法的具体用法?Python Page.content_type_for怎么用?Python Page.content_type_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feincms.module.page.models.Page
的用法示例。
在下文中一共展示了Page.content_type_for方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_content
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import content_type_for [as 别名]
def save_content(request):
"""
content save handler
Returns a HttpResponse whose content is JSON to tell if the operation succeeded.
"""
result = {"result": False}
if request.method == "POST":
if request.POST["content"]:
page_items = loads(request.POST["content"])
for content_key, item in page_items.iteritems():
# TODO: move to model/form cleaning
content = item["value"]
if settings.FEINCMS_TIDY_HTML:
content, errors, warnings = get_object(settings.FEINCMS_TIDY_FUNCTION)(content)
matches = re.search("^page-page-richtextcontent-(\d+)-(\d+)$", content_key)
if matches:
page_id, content_id = matches.group(1), matches.group(2)
# TODO: replace with more flexible solution (not tied to the RichTextContent model), as done in _frontend_editing_view
RTC = Page.content_type_for(RichTextContent)
rtc = RTC.objects.get(id=content_id, parent__id=page_id)
rtc.text = content
rtc.save()
# TODO: this should be done differently; being able to handle every page-item separartly (see formsets)
result = {"result": True}
return HttpResponse(dumps(result), content_type="application/json")
示例2: all
# 需要导入模块: from feincms.module.page.models import Page [as 别名]
# 或者: from feincms.module.page.models.Page import content_type_for [as 别名]
from __future__ import absolute_import, unicode_literals
from django.core.files import File as DjangoFile
from django.core.management.base import NoArgsCommand
from django.contrib.auth.models import User
from feincms.contents import FilerFileContent, FilerImageContent
from feincms.module.medialibrary.contents import MediaFileContent
from feincms.module.medialibrary.models import MediaFile
from feincms.module.page.models import Page
from filer.models import File, Image
PageMediaFileContent = Page.content_type_for(MediaFileContent)
PageFilerFileContent = Page.content_type_for(FilerFileContent)
PageFilerImageContent = Page.content_type_for(FilerImageContent)
assert all(
(PageMediaFileContent, PageFilerFileContent, PageFilerImageContent)
), "Not all required models available"
class Command(NoArgsCommand):
help = "Migrate the medialibrary and contents to django-filer"
def handle_noargs(self, **options):
user = User.objects.order_by("pk")[0]
count = MediaFile.objects.count()