I am passing a dictionary to my template with this view -
views.py
def personlist(request, id):
data = requests.get('http://127.0.0.1:8000/app_name/cities/' + id + '/persons/').json()
context = RequestContext(request, {
'persons': data['results'],'count': data['count'],
})
@register.filter(name='lookup')
def cut(value, arg):
return value[arg]
{{ mydict|lookup:item.name }}
return render_to_response('template.html', context)
where test_set
is a dictionary inside results
. I am using this view to render the template this way -
{% for person in persons %}
<a href="{% url 'person_detail' person.id %}"><p>{{person.name}}</p></a>
<p>{{person.test_set}}</p>
{% endfor %}
But that just displays the entire dictionary value - [{u'test_name': u'test', u'date': u'2015-12-15T20:57:51.556145Z'}]
while I just want the date. I tried using a custom template to try and use person.test_set.date
but it's not working.
Also, given the names and the dates is there a way to create a lookup to display names that were added on a daily/weekly/monthly basis?