我遵循的是来自answer的指令,为什么函数返回的对象是None而不是实体?你知道吗
class FileInfo(db.Model):
blob = blobstore.BlobReferenceProperty(required=True)
randomvalue = db.FloatProperty()
uploaded_by = db.UserProperty()
facebook_user_id = db.StringProperty()
uploaded_at = db.DateTimeProperty(required=True, auto_now_add=True)
category = db.CategoryProperty(choices=('eyes', 'nose', 'mouth',
'other'))
# snip -- shortened here
def get_random_image(self, category):
"""
fileinfos = FileInfo.all().filter('category =', category)
return fileinfos[random.randint(0, fileinfos.count() - 1)]
"""
q = FileInfo.all()
q.filter('category =', category)
q.filter('random >=', random.random())
return q.get() # why is this not working?
应更正为:
相关问题 更多 >
编程相关推荐