【问题标题】:Feincms find page with specific content typeFeincms 查找具有特定内容类型的页面
【发布时间】:2013-10-04 09:22:49
【问题描述】:

有没有办法找到包含特定内容类型的页面(查询)。

假设我有一个内容类型为LogoutFormContent 的页面(注销)。

如何找到内容类型为 LougOutFormContent 的页面。

我尝试过这样做:

page = Page.objects.filter(logoutformcontent_set=True)

生成以下查询

SELECT * FROM `page_page` INNER JOIN `page_page_logoutformcontent` 
ON (`page_page`.`id` = `page_page_logoutformcontent`.`parent_id`) 
WHERE (`page_page_logoutformcontent`.`id` = 1) 

这几乎是正确的,除了page_page_logoutformcontent.id = 1???

【问题讨论】:

    标签: feincms


    【解决方案1】:

    使用此功能找出哪些页面具有特定/给定的内容类型

    def get_page_for_ct(request, ct):
        ctp_page = Page.content_type_for(ct)
        page = ctp_page.objects.filter(parent__language=request.LANGUAGE_CODE)
        if not page:
            raise ImproperlyConfigured(
                    'page not found: "%s" for language "%s" '
                    % (ct, request.LANGUAGE_CODE))
        return page[0].parent
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多