Saturday, May 2, 2015

Re: Template syntax issues w dict

just a small correction – lose the parens after items:
{% for org, num in attendees_per_org.items %}

On Friday, May 1, 2015 at 4:48:25 AM UTC-3, ADEWALE ADISA wrote:

If I can understand your code, of seems you want a table of : Institution | Number of attendees
So if am right u can achive it this way :

{% for org, num in attendees_per_org.items() %}
            <tr>
                <td>{{ org }}</td>
                <td>{{ num }}</td>
            </tr>
  {% endfor %}

Since your dataset is a dictionary, u need to use key,value to get elements in both side. Also items() is also required.

On May 1, 2015 8:22 AM, "Lachlan Musicman" <dat...@gmail.com> wrote:

Hola,

Django shell gives right results, template doesn't: code here

http://dpaste.com/1NJEKD8

What am I doing wrong?

L.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiN78i37JA9UJov7%2BAVbJzRt4c5YCX3em2XvN-QmefxSvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d130722e-737a-4116-8522-1ddf64d697f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment