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 1055075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:30:23+00:00 2026-05-16T17:30:23+00:00

I query an array of objects from DB, then compare addresses of the objects

  • 0

I query an array of objects from DB, then compare addresses of the objects in Model and in View. They differs! Why? I want access the same objects as from template as from business logics code.

I wouldn’t ask for it but it really bother me because function calls are disallowed in Django-styled templates and I even can’t assign custom properties to DB-objects within the business logics code.

In request handler:

from google.appengine.ext.webapp import template

cats = db.GqlQuery("SELECT * FROM Cats")
for cat in cats:
  self.response.out.write("<li>%s</li>" % (a))

In template:

{% for a in articles %}
  {{a}},
{% endfor %}

Addresses (hash codes) differs in such code.

  • 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-16T17:30:24+00:00Added an answer on May 16, 2026 at 5:30 pm

    When you use the query iterator, you in fact do several fetches in sequence, each one will result in a new model instance.

    Instead of doing:

    cats = db.GqlQuery("SELECT * FROM Cats")
    for cat in cats:
        ...
    

    …do this instead:

    cats = db.GqlQuery("SELECT * FROM Cats").fetch(50)
    for cat in cats:
        ...
    

    And pass the list of cats to the template. You will have same lists in handler and template, as each entity is loaded into a model instance only once.

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

Sidebar

Related Questions

I've been learning about the Model-View-Controller paradigm (MVC), but I'm quite confused since some
I am using JDBC to query a MySQL database for specific records from two
from http://www.php.net/manual/en/class.pdo.php ###### config.ini ###### db_driver=mysql db_user=root db_password=924892xp [dsn] host=localhost port=3306 dbname=localhost [db_options] PDO::MYSQL_ATTR_INIT_COMMAND=set
Update: False alarm! The source of the error was elsewhere. (See at the end
I have a php script that handles the admin section/creation of pages for my
I have a php method that creates an HTML table with data it retrieves
We're designing an Android app that has a lot of data (customers, products, orders...),
I'm accessing the Amazon AWS API using the ruby-aaws gem, but without going to
I have this json {suggestions:[M.I.A.,M.,Mindless Self Indulgence,The Cure,Telefon Tel Aviv,M,J. Ralph,Jason Mraz,Carbon Based Lifeforms,Cycle

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.