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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:59:36+00:00 2026-05-13T12:59:36+00:00

I’m new to Python, and I’m using Google App Engine to build a simple

  • 0

I’m new to Python, and I’m using Google App Engine to build a simple blog to help me learn it. I have the following test code:

entries = db.Query(Entry).order("-published").get()
        comments = db.Query(Comment).order("published").get()
        self.response.out.write(template.render(templatePath + 'test.django.html', { 'entries': entries, 'comments': comments, }))

And a Django template that looks like this:

{% extends "master.django.html" %}

{% block pagetitle %}Test Page{% endblock pagetitle %}

{% block content %}

{% for e in entries %}

<p><a href="/post/{{ e.slug }}/">{{ e.title|escape }} - {{ e.published|date:"jS o\f F Y" }}</p>

{% endfor %}

{% for c in comments.all %}

<p>{{ c.authorname }} {{ c.published|date:"d/m/Y h:i" }}</p>

{% endfor %}

{% endblock content %}

When I view this templated page in the browser, I get:

TypeError: 'Entry' object is not iterable

Changing the line {% for e in entries %} to {% for e in entries.all %} solves this problem, which is great.

However, this is the bit I don’t understand; in another template (for the archive page), I pass in the same thing, a list of Entry objects:

entries = db.Query(Entry).order("-published").fetch(limit=100)
        self.response.out.write(template.render(templatePath + 'archive.django.html', { 'entries': entries, }))

With the template as follows:

{% extends "master.django.html" %}

{% block pagetitle %}Home Page{% endblock pagetitle %}

{% block content %}

<ul>

{% for entry in entries %}

<li><a href="/post/{{ entry.slug }}/">{{ entry.title|escape }} <span>{{ entry.published|date:"jS o\f F Y" }}</a>{% if admin %} - <a href="/compose/?key={{ entry.key }}">Edit Post</a>{% endif %}</span></li>

{% endfor %}

{% endblock content %}

This code works fine, without changing entries to entries.all; indeed if I do change it to that I get no output (no errors, just nothing at all).

Can someone explain why this is please?

Edit: I originally pasted the wrong piece of query code for the second example, which would probably have made things easier for people to give me an answer… changed it now.

  • 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-13T12:59:37+00:00Added an answer on May 13, 2026 at 12:59 pm

    You want to use .fetch(), not get():

    entries = db.Query(Entry).order("-published").fetch()
    comments = db.Query(Comment).order("published").fetch()
    

    get() returns only the first item that matches the query criteria, so instead of an iterable collection, you’ll get one instance, and Entry object.

    I can not explain why the second version does work. It really looks like it shouldn’t.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't

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.