开发者

how to get all 'username' from my model 'MyUser' on google-app-engine

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜