PageRenderTime 43ms CodeModel.GetById 23ms RepoModel.GetById 1ms 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
Possible License(s): LGPL-3.0
  1. # -*- coding: utf-8 -*-
  2. # django
  3. from django.shortcuts import get_object_or_404
  4. # site
  5. from view_shortcuts.decorators import render_to
  6. from view_shortcuts.filters import FilterList
  7. # app
  8. from models import Story
  9. facets = (
  10. facet('category'),
  11. facet('author__pk', 'author', AlphabetRelationFilter),
  12. facet('status'),
  13. )
  14. @render_to()
  15. def story_list(request):
  16. items = Story.objects.all() #filter(status=Story.PUBLISHED)
  17. filters = FilterList(request, items, params=FILTER_MAP)
  18. # another_query = filters.object_list.filter(foo='bar')
  19. return dict(filters=filters)
  20. @render_to()
  21. def story_detail(request, object_id):
  22. obj = get_object_or_404(Story, pk=object_id)
  23. return dict(object=obj)