python - Django query question -


I have a View & amp; A template that displays a list of items types is fine, but rather than displaying all kinds of items for that customer. What do I want to do, list of type individually is displayed For example, if an item is a type stored, say "normal". I want to display all the items that have only one type called "normal".

View

  def client_summary (request, client_id): Client = any item = no attempt: client = model. Client.com.gate (pk = client_id) item = client.storageitem_set.all (excluding total_items = items.count (): Return HttpResponse (reverse (return_clients)) return to render_to_response ('client_summary.html', {'item'   {item}, 'total_times': total_times, 'customer': client}, context_instance = RequestContext (request))   

template

 Client.name}} Total number of items: {{total_items}} {% for item in items} {{item.type}} {% endfor%}    

You can try 'client.storageitem_set.filter' (type = YOUR_TYPE):

  def client_summary (request, client_id): customer = any item = no attempt: client = model Clients.Abjects Returns (Returns / Sentences) Returns Render_to_protection ('Client_smurry') Returns (Returns / Returns) Returns (Returns)  / pre> 

docs: Html>

Comments