当前位置: 首页>>代码示例>>Python>>正文


Python models.FlatPage方法代码示例

本文整理汇总了Python中django.contrib.flatpages.models.FlatPage方法的典型用法代码示例。如果您正苦于以下问题:Python models.FlatPage方法的具体用法?Python models.FlatPage怎么用?Python models.FlatPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.flatpages.models的用法示例。


在下文中一共展示了models.FlatPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: flatpage

# 需要导入模块: from django.contrib.flatpages import models [as 别名]
# 或者: from django.contrib.flatpages.models import FlatPage [as 别名]
def flatpage(request, url):
    """
    Public interface to the flat page view.

    Models: `flatpages.flatpages`
    Templates: Uses the template defined by the ``template_name`` field,
        or :template:`flatpages/default.html` if template_name is not defined.
    Context:
        flatpage
            `flatpages.flatpages` object
    """
    if not url.startswith('/'):
        url = '/' + url
    site_id = get_current_site(request).id
    try:
        f = get_object_or_404(FlatPage, url=url, sites=site_id)
    except Http404:
        if not url.endswith('/') and settings.APPEND_SLASH:
            url += '/'
            f = get_object_or_404(FlatPage, url=url, sites=site_id)
            return HttpResponsePermanentRedirect('%s/' % request.path)
        else:
            raise
    return render_flatpage(request, f) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:26,代码来源:views.py

示例2: flatpage

# 需要导入模块: from django.contrib.flatpages import models [as 别名]
# 或者: from django.contrib.flatpages.models import FlatPage [as 别名]
def flatpage(request, url):
    """
    Public interface to the flat page view.

    Models: `flatpages.flatpages`
    Templates: Uses the template defined by the ``template_name`` field,
        or :template:`flatpages/default.html` if template_name is not defined.
    Context:
        flatpage
            `flatpages.flatpages` object
    """
    if not url.startswith('/'):
        url = '/' + url
    site_id = get_current_site(request).id
    try:
        f = get_object_or_404(FlatPage,
            url=url, sites=site_id)
    except Http404:
        if not url.endswith('/') and settings.APPEND_SLASH:
            url += '/'
            f = get_object_or_404(FlatPage,
                url=url, sites=site_id)
            return HttpResponsePermanentRedirect('%s/' % request.path)
        else:
            raise
    return render_flatpage(request, f) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:28,代码来源:views.py

示例3: setUp

# 需要导入模块: from django.contrib.flatpages import models [as 别名]
# 或者: from django.contrib.flatpages.models import FlatPage [as 别名]
def setUp(self):
        self.page = FlatPage(title='Café!', url='/café/') 
开发者ID:nesdis,项目名称:djongo,代码行数:4,代码来源:test_models.py


注:本文中的django.contrib.flatpages.models.FlatPage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。