我正在从firebase获取数据
视图.py
def posts (request):
_posts= ref.child('posts').get(); #getting data from firebase
#_posts={u'1536855154789':
# {u'content': u'Yahoo! The sports day is near!!',
# u'image': u'https://firebasestorage.googleapis.com/.../img_1536855147507.jpeg?',
# u'title': u'Sports Day'},
#u'-LMJBAc3iZRklICAwDC1':
# {u'content': u'Find the chef in your child. Food fest is here!!',
# u'image': u'https://firebasestorage.googleapis.com/.../img_1536863277649.jpeg?',
# u'title': u'Food Fest '},
#u'-LNaLKKqSIZHraf3oedT':
# {u'content': u'Exploring is part of education. Hence a tour to Historical and Cultural Heritage monuments in Delhi has been planned.',
# u'image': u'https://firebasestorage.googleapis.com/.../img_1538241669221.jpeg',
# u'title': u'Educational Tour'}}
return render(request, 'post.html', {'postList': _posts})
索引.html
{% for item in postList %}
{{ item.title}}</br>
{% endfor %}
一无所获
我的firebase数据 https://i.stack.imgur.com/lxYsC.png
帮我解决这个问题。提前谢谢
如果你有一个dict列表,你的代码就可以运行了。但你没有;您有一个字典,它的键是id,值本身就是dict。所以需要迭代dict值:
相关问题 更多 >
编程相关推荐