John Smith John Smith - 4 months ago 11
Python Question

How do I parse this data in a Django template?

{u'4th-of-July': {'name': 4th of July', 'slug': u'4th-of-July'}}


I would like to have access to
'name'
and
'slug'
in a django HTML template. How do I go about doing this?

Answer

You can access a dict in template with dot notation:

Let's call your dictionary data:

{{ data.4th-of-July.name }}

And

{{ data.4th-of-July.slug }}