my model is :
class MyUser(db.Model):
username = db.StringProperty()
password = db.StringProperty(default=UNUSABLE_PASSWORD)
email = db.StringProperty()
nickname = db.StringProperty(indexed=False)
and my method which want to get all username is :
s=[]
a=MyUser.all()
for i in a:
s.append(i.username)
and i want to know : has any other way to show all 'usernam开发者_开发百科e' .
thanks
Yes, there are many other ways to show all usernames. One is templates:
users = MyUser.all()
template.render('userlist.html', {'users': users})
<ul>
<% for user in users %>
<li>{{ user.username }}</li>
<% endfor %>
</ul>
精彩评论