views:

30

answers:

1

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 'username' .

thanks

A: 

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>
Drew Sears