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


Python Album.pictures_id_list方法代码示例

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


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

示例1: album

# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import pictures_id_list [as 别名]
def album(request, album_id, lang="en", name=""):
    if album_id == "0":
        query = request.GET.get("query", " ")
        album = Album(query=query)
        album.id = 0

    else:
        album = get_object_or_404(Album, id=album_id)
    try:
        page = int(request.GET.get("page", "1"))
    except ValueError:
        page = 1

    if request.GET.get("redirect", "") != "":
        if album_id == "0" and page == 1:
            goto = reverse("wilson:custom_album", kwargs={"lang": translation.get_language(), "query": query})
        elif album_id == "0" and page > 1:
            goto = reverse(
                "wilson:custom_album", kwargs={"lang": translation.get_language(), "page": page, "query": query}
            )
        elif page == 1:
            goto = reverse(
                "wilson:album",
                kwargs={"lang": translation.get_language(), "album_id": album_id, "name": slugify(album.title())},
            )
        else:
            goto = reverse(
                "wilson:album_page",
                kwargs={
                    "lang": translation.get_language(),
                    "album_id": album_id,
                    "name": slugify(album.title()),
                    "page": page,
                },
            )
        return HttpResponseRedirect(goto)

    paginator = Paginator(album.pictures_id_list(), 35, 7)

    # If page request (9999) is out of range, deliver last page of results.
    try:
        album_pics = paginator.page(page)
    except (EmptyPage, InvalidPage):
        album_pics = paginator.page(paginator.num_pages)
    album_pics.page_range = paginator.page_range
    return render_to_response(
        "wilson/album.html",
        {
            "album": album,
            "album_pics": album_pics,
            "menu": {
                "left": list(MenuPlaceholder.objects.filter(parent=None, position_h="l").order_by("position_v")),
                "right": list(MenuPlaceholder.objects.filter(parent=None, position_h="r").order_by("position_v")),
            },
        },
        context_instance=RequestContext(request),
    )
开发者ID:hwmrocker,项目名称:gweb,代码行数:59,代码来源:views.py


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