django - How to iterate over list of dictionary in python? -


i have list of dictionary in python i.e.

listofobs = [{'timestamp': datetime.datetime(2012, 7, 6, 12, 39, 52), 'ip': u'1.4.128.0', 'user': u'lovestone'}, {'timestamp': datetime.datetime(2012, 7, 6, 12, 40, 32), 'ip': u'192.168.21.45', 'user': u'b'}] 

i want use of keys , value of listofobs variable in django-template. example:

for first iteration:

timestamp = 7 july 2012, 12:39 ip = 1.4.128.0 user = lovestone 

and second iteration :

 timestamp = 7 july 2012, 12:40 ip = 192.168.21.45 user = b 

and on ..

for in listofobs: print str( a['timestamp'] ), a['ip'], a['user'] 

will iterate on list of dict's, use them in template wrap in needed django syntax , quite similar regular python.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -