I am a newbie to Django.. I am wondering why I am getting 'Caught an
exception while rendering: 'Car' object is not iterable?

As per my understanding,  in the template, if statement should not be
true and else portion should be executed.

Can anybody help me on this?


View:
--------

def v_list(request,car_number=None):

    try:
        if car_number!=None:
            car_list=Car.objects.get(id=car_number)
        else:
            car_list=Car.objects.order_by('name')

    except:
        raise Http404('Requested Info. not found')
     cars_render=RequestContext(request,{'car_list':car_list})
    return render_to_response('cars.html',cars_render)

Template:
-------------
   {% if car_list %}
            {% for car in car_list %}
                 {{car.id}} ,{{car.name}}
            {% endfor %}

    {%else%}
            {{car_list.name}}
    {% endif %}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to