Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. url(r'^(?i)book/(?P<chapter>[w.-]+)/?(?P<section>[w.-]+)/?$', 'book.views.chaptersection'),
  2.  
  3. from book.models import contents as C
  4. def chaptersection(request, chapter, section):
  5.  
  6. if chapter and section:
  7.  
  8. chapter = chapter.replace('-', ' ')
  9. section = section.replace('-', ' ')
  10.  
  11. info = C.objects.filter(chapter__iexact=chapter, section__iexact=section).order_by('symb')
  12. context = {'info':info}
  13. return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
  14.  
  15. elif chapter:
  16.  
  17. chapter = chapter.replace('-', ' ')
  18.  
  19. info = C.objects.filter(chapter__iexact=chapter).order_by('symb')
  20. context = {'info':info}
  21. return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
  22.  
  23. else:
  24. info = C.objects.all().order_by('symb')
  25. context = {'info':info}
  26. return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
  27.  
  28. (?P<section>[w.-]+)
  29.  
  30. (?P<section>[w.-]*)
  31.  
  32. url(r'^(?i)book/(?P<chapter>[w.-]+)/$', 'book.views.chaptersection'),
  33. url(r'^(?i)book/(?P<chapter>[w.-]+)/(?P<section>[w.-]+)/$', 'book.views.chaptersection'),
  34.  
  35. def chaptersection(request, chapter, section=None):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement