개체를 템플릿에 전달하기 전에 복잡한 정렬을 어떻게 수행 할 수 있습니까? 예를 들어, 내 시야는 다음과 같습니다.Django 템플릿의 목록을 정렬 및 인덱싱 하시겠습니까?
@login_required
def overview(request):
physicians = PhysicianGroup.objects.get(pk=physician_group).physicians
for physician in physicians.all():
physician.service_patients.order_by('bed__room__unit', 'bed__room__order', 'bed__order')
return render_to_response('hospitalists/overview.html', RequestContext(request, {'physicians': physicians,}))
의사 개체가 템플릿에서 올바르게 정렬되지 않았습니다. 왜 안돼?
또한 템플릿의 목록에 어떻게 색인을 생성합니까? 예를 들어, (이 작동하지 않음) :
{% for note_type in note_types %}
<div><h3>{{ note_type }}</h3>
{% for notes in note_sets.index(parent.forloop.counter0) %}
#only want to display the notes of this note_type!
{% for note in notes %}
<p>{{ note }}</p>
{% endfor %}
{% endfor %}
</div>
{% endfor %}
감사 잔뜩 피트
@ 피터 모텐슨, 왜 당신이 주변 사람들의 게시물에서 감사를 제거 가야합니까? 이 질문의 개정판 # 8을보십시오. 나는 이것을 받아 들일 수 없다. – slypete