I came across this tutorial:
http://thomas.broxrost.com/2008/04/08/django-on-google-app-engine/
Fantastic!
Everything worked.
I just did not fully understand the code below because in comparison to Django it seems different:
views.py:
def main(request):
visitor = Visitor()
visitor.ip = request.META["REMOTE_ADDR"]
visitor.put()
result = ""
visitors = Visitor.all()
visitors.order("-added_on")
for visitor in visitors.fetch(limit=40):
result += visitor.ip + u" visited on " + unicode(visitor.added_on) + u""
return HttpResponse(result)
#model.py:
from google.appengine.ext import db
class Visitor(db.Model):
ip = db.StringProperty()
added_on = db.DateTimeProperty(auto_now_add=True)
What exactly is Visitor() ? A tuple a list?
And what does visitor.ip , visitor.put(), visitors.fetch() do exactly?
I believe:
visitor.ip saves the request.META["REMOTE_ADDR"] in the db field.
visitor.put() saves it.
visitors.fetch(limit = 40) extracts it from the db.
What I was trying to do is a tenplate that lists every IP below the next one.
I believed:
<p><ol><Li> {{ result }} </li></ol></p>
Would do the trick.
But it didn't.
Thanks !