On 8/17/2010 1:53 PM, djnubbio wrote: > hi all and tank in advance for wasting your time; i'm very newby in > django framework > > I have the following: > > > > #views.py > ... > def lista_diario(request, comm_id): > comm_list = > Commessa.objects.all().annotate(oretot=Sum('diario__ore')) > return render_to_response('commesse/lista_diario.html', > dict(comm_list=comm_list, zxc= comm_id )) > > ... > #lista_diario.html > > ... > {% for comm in comm_list %} > > ... > {% if comm.id == zxc %} > > > do something > > {% endif %} > ... > {% endfor %} > > the trouble is that the if condition is never TRUE, because comm.id > has its proper value, but zxc is empty. > > any suggestione will be greatly appreciated. > > Are you *sure* zxc is empty? It's much more likely that it isn't the same type as comm.id. In Python 1 != "1", so you may find that your code works if you start the lista_diaro() function with
comm_id = int(comm_id) Remember that if there's any chance that comm_id might not contain an integer you will need error checking and handling. If it's actually verified by the urlconf pattern, however, then errors won't occur. regards Steve -- DjangoCon US 2010 September 7-9 http://djangocon.us/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.