python 2.7 - Comparing string with django request -
i have doubt, developing websites , using django-categories, got problem might sounds stupid cannot understand. case trying url /blog/c/categoria1/subcategoria11/subcategoria-3 , in database have 2 registers coincides finishing subcategoria-3 know second 1 correct.
blog/views.py
def categoria(request ): category = getcategory(request.path) return render_to_response('blog/categoria.html',{'categoria':category},requestcontext(request)) def getcategory(url): categories = url.split('/') category in category.objects.filter(slug = categories[-1]): if category.get_absolute_url == url: return category return false
blog/categoria.html
{{categoria}}<br> {{request.path}}
the html generated is
false<br> /blog/c/categoria1/subcategoria11/subcategoria-3
but if modify getcategory function code
def getcategory(url): categories = url.split('/') category in category.objects.filter(slug = categories[-1]): if category.get_absolute_url == url: return category return category.get_absolute_url #i receive absolute_url of second register correct 1 return false
with function html generated
/blog/c/categoria1/subcategoria11/subcategoria-3<br> /blog/c/categoria1/subcategoria11/subcategoria-3
if receive response, don't know why receive false value , not category when comparison second register
Comments
Post a Comment