开发者

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

开发者 https://www.devze.com 2023-01-02 04:10 出处:网络
my model is : class MyUser(db.Model): username = db.StringProperty() password = db.StringProperty(default=UNUSABLE_PASSWORD)

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

精彩评论

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