view.py
def show(request):
c_name=database.child('shortterm').get().val()
return render(request,"index.html",{"c_name":c_name})
firebase
index.html
<p>{{ c_name }}</p>
how to fetch multiple objects (under shortterm node) from firebase and display in table format?
You're loading the entire shortterm
node from the database, so your c_name
variable ends up being that entire branch of your database as a dictionary/map.
Since you won't know the push key (`"-Msyly..."), you will need to loop over the results to get that:
def show(request):
data=database.child('shortterm').get().val()
for key in data:
print(key, data[key])
c_name = data[key]
return render(request,"index.html",{"c_name":c_name})
Also see:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.