开发者

Guestbook application

I made a very minor mod to the GqlQuery to retrieve only specified records us开发者_如何学Pythoning the 'where' keyword. The output, however, displays all entries from the guestbook db! (I need to filter the data by author)

Guestbook5_datastore code:

#greetings = db.GqlQuery("SELECT * FROM Greeting ORDER BY date DESC LIMIT 10")
greetings = db.GqlQuery("SELECT * FROM Greeting where greeting.author='mike'")

index.html code:

{% for greeting in greetings %}
  {% if greeting.author %}
    <b>{{ greeting.author.nickname }}</b> wrote:
  {% else %}
   An Anonymous person wrote:
  {% endif %}
  <blockquote>{{ greeting.content|escape }}</blockquote>
{% endfor %}


Your author property is not a string, so I don't think you can do

greeting.author='mike'

I'm surprised that you wouldn't get an error telling you that though, rather than it returning them all!


You're attempting to filter based on a property of another entity, which would require a join. This isn't supported in App Engine.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜