從本質上講,似乎我的數據是從數據庫中提取的,但我收到地址而不是字符串本身。我想從數據庫中得到的是一個3個朋友的個人資料頁面列表(stringproperties)。從For循環接收內存地址
這是我的DB類:
class Friends(db.Model):
name = db.StringProperty(required = True)
friend = db.StringProperty()
added_date = db.DateTimeProperty(auto_now_add = True)
我的資料處理程序:
class Profile(MainHandler):
def get(self, profile_id):
if self.user and profile_id:
current_user = self.user.name
name1 = ''
friend_name = ''
team_imagee = ''
key = ''
imgs = db.GqlQuery("select * from Profile_Images WHERE name =:1", profile_id)
team_name = db.GqlQuery("select * from Teams WHERE name =:1", profile_id)
team_images = db.GqlQuery("select * from Teamimg WHERE user =:1", profile_id)
friends = db.GqlQuery("select * from Friends WHERE name =:1 order by added_date desc limit 10", profile_id)
for clan in team_name:
name1 = clan.team_name_anycase
for image in team_images:
team_imagee = image.key()
for img in imgs:
key = img.key()
self.render('profile.html', profile_id = profile_id, current_user = current_user, friends = friends, team_img = team_imagee, team_name = name1, profile_image = key, username = self.user.name, email = self.user.email, firstname = self.user.first_name, last_name = self.user.last_name, country = self.user.country)
else:
self.redirect('/register')
而在我的模板循環:
{% for friend in friends %}
{{friend}}
<br>
{% endfor %}
是否有人會告訴我爲什麼我有時會看到這些地址而不是對象本身(即使只是一般)。
下面的兩個答案都是正確的,如果您正在迭代整個實體,您希望顯示什麼?你想要的是訪問該對象的屬性,我猜... – aschmid00 2012-08-16 21:23:42