Getting template syntax error while trying to parse a dictionary in my template in django -


ok here code of view.

def customers_to_be_called(request):     customers = customer.objects.filter(call=true)     list_of_customers = []     cust in customers:         jobs = job.objects.filter(customer = cust)         customer_date = {}         customer_data['customer'] = cust         customer_date['jobs'] = jobs         list_of_customers.append(customer_data)      return render(request, 'repairs/customers_to_be_called.html',            {'list_of_customers' : list_of_customers,     }) 

and here template gonna rendered

<div> {% customer in list_of_customers %}     <h2> {{customer['customer'].name}} </h2>     <ul>     {% job in customer['jobs'] %}         <li> {{job.product}} </li>     {% endfor %}     </ul> {% endfor %} </div> 

but when send request page following error. error

i don't know why isn't parsing customer in template while there data in it..??

to refer dict item customer.jobs not customer['jobs']

so loop becomes

{% customer in list_of_customers %}     <h2> {{customer.customer.name}} </h2>     <ul>     {% job in customer.jobs %}         <li> {{job.product}} </li>     {% endfor %}     </ul> {% endfor %} 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -