PageRenderTime 166ms CodeModel.GetById 80ms app.highlight 9ms RepoModel.GetById 72ms app.codeStats 0ms

/example_app/views.py

https://bitbucket.org/neithere/django-view-shortcuts/
Python | 27 lines | 18 code | 4 blank | 5 comment | 0 complexity | 32576e60513ab0809912ebd936997406 MD5 | raw file
 1# -*- coding: utf-8 -*-
 2
 3# django
 4from django.shortcuts import get_object_or_404
 5# site
 6from view_shortcuts.decorators import render_to
 7from view_shortcuts.filters import FilterList
 8# app
 9from models import Story
10
11facets = (
12    facet('category'),
13    facet('author__pk', 'author', AlphabetRelationFilter),
14    facet('status'),
15)
16
17@render_to()
18def story_list(request):
19    items = Story.objects.all() #filter(status=Story.PUBLISHED)
20    filters = FilterList(request, items, params=FILTER_MAP)
21    # another_query = filters.object_list.filter(foo='bar')
22    return dict(filters=filters)
23
24@render_to()
25def story_detail(request, object_id):
26    obj = get_object_or_404(Story, pk=object_id)
27    return dict(object=obj)