Django Master/Detail Template -


i have 2 classes define 2 models

class master(models.model):     date = models.datetimefield()     status = models.charfield(default = 'r')  class detail(models.model):     name = models.textfield()     = models.foreignkey(master) 

the view:

def list_view(request):     masters = master.objects.filter()     context = {'masters': masters}     return render_to_response('list.html', context, context_instance = requestcontext(request)) 

the template:

{% master in masters %}     <tr>         <td>{{ master.date }}</td>         <td>{{ master.status }}</td>         <td>{# #}</td>     </tr> {% endfor %} 

i want show detail names in {# #} section, don't know how modify view that. how can access details master in template?

you can names

{% master in masters %}     <tr>         <td>{{ master.date }}</td>         <td>{{ master.status }}</td>         <td>            {% detail in master.detail_set.all %}                {{detail.name}}<br/>            {% endfor %}                 </td>     </tr> {% endfor %} 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -