def section request path path path split if len path 31 raise Http404

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def section(request, path):
path = path.split('/')
if len(path)>31:
raise Http404
flt = {}
while path:
flt['parent__' * len(flt) + 'slug'] = path.pop()
flt['parent__' * (len(flt)-1) + 'language'] = request.LANGUAGE_CODE
try:
item = Section.objects.get(**flt)
except Section.DoesNotExist:
raise Http404