I have seen similar questions asked on the same topic, which is coding a very simple blog with Python and hosted on GAE. Apologies if I have missed the solution in one of the answers.
I can't see any database entries being displayed at all. Here is my code:
Entity:
class Comment(db.Model):
name = db.StringProperty(required=True)
comment = db.TextProperty(required=True)
created = time.strftime("%d/%m/%Y")
Main Handler:
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("/")
So this will be displayed in the 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 %}
The problem is that the program seems to completely ignore the above for block. I managed to make it work for a while but I checked it many times and can't see where the problem is.
Any help will be appreciated. Thanks in advance.