Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1030203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:39:48+00:00 2026-05-16T12:39:48+00:00

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

  • 0

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 !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:39:49+00:00Added an answer on May 16, 2026 at 12:39 pm

    Visitor is a class, and each field in it represents a column in your database.
    When you do visitor = Visitor() you’re essentially creating a new row in your database. Calling visitor.put() is what actually commits it into the database. Visitors.all() returns a all the rows in the db (it’s either a list, tuple, or dictionary), so then visitors.fetch() is just an operation on that.

    The reason your template isn’t working is because your function in views.py isn’t specifying any template. This is taken from the Django tutorial: http://docs.djangoproject.com/en/1.0/intro/tutorial03/

    from django.template import Context, loader
    from mysite.polls.models import Poll
    from django.http import HttpResponse
    
    def index(request):
        latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
        t = loader.get_template('polls/index.html')
        c = Context({
            'latest_poll_list': latest_poll_list,
        })
        return HttpResponse(t.render(c))
    

    The parameter for Context() is a dictionary. The string on the left is what the name of the variable will be within the template, and the right side is what actual variable that it corresponds to. In your example you can use {'mylist': result}, and in your template you could use {{ mylist }} instead of {{ result }}

    You also need to make sure to set a template directory in settings.py which the template (in the above example) is polls/index.html within that template dir.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across this oAuth library for ActionScript 3.0. http://code.google.com/p/oauth-as3/ It seems to have
I came accross this html multiple file upload tutorial: http://robertnyman.com/2010/12/16/utilizing-the-html5-file-api-to-choose-upload-preview-and-see-progress-for-multiple-files/ I'm new to web
I adapted this tutorial (http://www.screaming-penguin.com/node/7749) to an Android app I've built to allow for
I'm working through the NerdDinner MVC tutorial and came across this and was wondering
Came across this code: <?php require_once 'HTTP/Session/Container/DB.php'; $s = new HTTP_Session_Container_DB('mysql://user:password@localhost/db'); ini_get('session.auto_start') or session_start();
I was reading the ctypes tutorial, and I came across this: s = Hello,
Came across this error when trying out the ruby on rails tutorial section with
I recently came across this variable initialization in a WebGL tutorial: var mouse =
I was doing a Junit tutorial and I came across this normalize function that
Trying to learn Ruby, and in a tutorial, I came across this code on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.