本文整理汇总了Python中models.Page.filter方法的典型用法代码示例。如果您正苦于以下问题:Python Page.filter方法的具体用法?Python Page.filter怎么用?Python Page.filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Page
的用法示例。
在下文中一共展示了Page.filter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_request_context
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import filter [as 别名]
def make_request_context(dic=None):
from limited.utils import widgets
from models import Page, Tag, User
from viewutils import get_latest_comments
if dic is None:
dic = {}
static_files = GroupedDict(find_static_files())
dic.update((key, getattr(settings, key)) for key in ("BLOG_URL", "MEDIA_URL", "ADMINS", "USE_PYGMENTS"))
dic.update(DEFAULT_CONTEXT_VARIABLES)
dic.update(
{
"navigation_top": [HomePage()] + list(Page.filter(in_navigation=True)),
"tags": Tag.objects.all().order_by("-name"),
"latestcomments": get_latest_comments(),
"popular_pages": Page.filter(popular=True),
"WIDGETS": widgets.get_widgets(),
"JS_FILES": static_files["js"],
"CSS_FILES": static_files["css"],
"limited": _internal.software_info(),
}
)
if not "COPYRIGHT_YEARS" in dic:
from datetime import datetime
dic["COPYRIGHT_YEARS"] = [datetime.now().year]
assert 0 < len(dic["COPYRIGHT_YEARS"]) < 3
# two years at maximum
return dic
示例2: get_popular_pages
# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import filter [as 别名]
def get_popular_pages(isblog=False):
"""
Get Page items marked as popular
@param isblog: `True` if only blog entries should be returned
@returns: a list of NavLink instances containing the links
"""
return Page.filter(popular=True).order_by("-creation_time")