예제 #1
0
def galleries(request, page=None):
    gallery_list = [
        {
            'img': "photos/img/%s" % g.photos.first().thumbnail,
            'id': g.id,
            'title': g.name
        }
        for g in Gallery.objects.filter(is_draft=False)
    ]

    paginator = Paginator(gallery_list, 3)
    topics = Theme.objects.filter(parent=None)
    galleries = custom_pagination(paginator, page)
    ctx = {'galleries': galleries, 'topics': topics}
    return render_to_response('photos/galleries.html', ctx)
예제 #2
0
def gallery(request, pk=None, page=None):
    """ decided to only have 6 per gallery
    need to link from up load dir to static
    in static/photos/ ln -s /opt/band/media/* ./
    for real need to fix properly
    """
    photo_list = [
        {
            'img': "photos%s" % g.image.url.replace('/media', '/img'),
            'id': g.id,
            'title': g.name,
            'comment': g.comment,
        }
        for g in Gallery.objects.get(pk=pk).photos.all()
    ]

    paginator = Paginator(photo_list, 6)
    topics = Theme.objects.filter(parent=None)
    photos = custom_pagination(paginator, page)
    ctx = {'photos': photos, 'topics': topics}
    return render_to_response('photos/gallery.html', ctx)