我在同一主題上看到過類似的問題,它使用Python編寫了一個非常簡單的博客,並在GAE上託管。如果我錯過了其中一個答案中的解決方案,我很抱歉。Google App Engine上的簡單博客 - 沒有任何條目正在顯示
我看不到任何正在顯示的數據庫條目。這裏是我的代碼:
實體:
class Comment(db.Model):
name = db.StringProperty(required=True)
comment = db.TextProperty(required=True)
created = time.strftime("%d/%m/%Y")
主要處理程序:
class MainPage(Handler):
def render_front(self, name="", comment="", error=""):
comments = db.GqlQuery("SELECT * FROM Comment ORDER BY created DESC")
self.render("front.html", name=name, comment=comment, error=error, comments=comments)
def get(self):
self.render_front()
def post(self):
name = self.request.get("name")
comment = self.request.get("comment")
if name and comment:
c = Comment(name=name, comment=comment)
c.put()
time.sleep(0.5)
self.redirect("/")
因此,這將顯示在HTML:
{% for e in comments %}
<div class="comment">
<div class="comment-name">
{{e.name}}
</div>
<pre class="comment-content">
{{e.comment}}
<br>
on {{e.created}}
</pre>
</div>
{% endfor %}
的問題是,該程序似乎完全忽略了上面的塊。我設法讓它工作了一段時間,但我多次檢查過,看不清問題出在哪裏。
任何幫助將不勝感激。提前致謝。
你是如何設法使它工作的?您是否還檢查過App Engine日誌文件以查找錯誤?通常至少點你在正確的方向.. – Totem
幾種方法來檢查通過這個: –