Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- url(r'^(?i)book/(?P<chapter>[w.-]+)/?(?P<section>[w.-]+)/?$', 'book.views.chaptersection'),
- from book.models import contents as C
- def chaptersection(request, chapter, section):
- if chapter and section:
- chapter = chapter.replace('-', ' ')
- section = section.replace('-', ' ')
- info = C.objects.filter(chapter__iexact=chapter, section__iexact=section).order_by('symb')
- context = {'info':info}
- return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
- elif chapter:
- chapter = chapter.replace('-', ' ')
- info = C.objects.filter(chapter__iexact=chapter).order_by('symb')
- context = {'info':info}
- return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
- else:
- info = C.objects.all().order_by('symb')
- context = {'info':info}
- return render_to_response('chaptersection.html', context, context_instance=RequestContext(request))
- (?P<section>[w.-]+)
- (?P<section>[w.-]*)
- url(r'^(?i)book/(?P<chapter>[w.-]+)/$', 'book.views.chaptersection'),
- url(r'^(?i)book/(?P<chapter>[w.-]+)/(?P<section>[w.-]+)/$', 'book.views.chaptersection'),
- def chaptersection(request, chapter, section=None):
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement