开发者

for loop counter django print in html

i want to print a patient receipt dat contain following detail: name ,uid,age,height............... email,medicine,dosage..etc.

now my question is how can i print the medicine foreg:medicine-1,medicine-2,medicine-3....n sooo on... in html..

{% for pmed in meds %}

Medicine

{% endfor %}

but actually in want to print in html like this way:my first half part is running bcoz it can single data... eg:

patient name: {{patient.name}} 
uhid: {{patient.uhid}} 
age: {{patient.age}} 
Gender: {{patient.gender}} 
Height: {{patient.height}} 
Weight: {{patient.weight}}

but the problem is with medicine part.. as for one patient their will b let say 3 medicine... so can i print the medicine part.. in html. well my trying this as follows:

{% for pmed in meds %} 
    {{pmed.medicine-开发者_StackOverflowforloop.counter}} 
    like for medicine-1:crocin, medicine-2:paraseta 
{% endfor %}

im not getting exactly.. can u help me out.

thanx in advance.


Try:

{% for pmed in meds %} 
    Medicine - {{ forloop.counter }} : {{ pmed.medicine }} 
{% endfor %}


{% for pmed in meds.values %}
    Weight: {{pmed.weight}}
    {% for medicine in pmed.medicines %}
        medince: {{ medicine.name }}
    {% endfor %}
{% endfor %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜