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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:07:10+00:00 2026-06-12T06:07:10+00:00

When I load the html page the results from the database are not appearing.

  • 0

When I load the html page the results from the database are not appearing. I am using python and jinja2. The {{ initial_city }} is displaying the correct results, the problem seems to be with get_deals or on the html file where I have used jinja2. I want to display results that equal to the city chosen on the main page (it is a form). Also, I have entities in the database, which appear when going onto the google datastore local extension

the get_deals code is:

    def get(self):
        def get_deals(choose_city, update=False):
            key = str(choose_city)
            all_deals = memcache.get(key)
            if all_deals is None:
                d = Deal.all()
                all_deals = d.filter('city = ', choose_city)
                all_deals = list(all_deals)
                memcache.set(key, all_deals)
           return all_deals

Below are my scripts:

from google.appengine.ext import db
from google.appengine.api import memcache
from google.appengine.ext.db import stats
from models import Deal
import os
import webapp2
import jinja2



class Deal(db.Model):
   title = db.TextProperty()
   description = db.TextProperty()
   city = db.TextProperty()

 deal = Deal(title='Hello',
        #description='Deal info here',
        #city='New York')
 deal.put()



jinja_environment = jinja2.Environment(autoescape=True,
    loader=jinja2.FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')))

class MainPage(webapp2.RequestHandler):
  def get(self):
      template = jinja_environment.get_template('index.html')
      self.response.out.write(template.render())


class DealHandler(webapp2.RequestHandler):
    def get(self):
        def get_deals(choose_city, update=False):
            key = str(choose_city)
            all_deals = memcache.get(key)
            if all_deals is None:
                d = Deal.all()
                all_deals = d.filter('city = ', choose_city)
                all_deals = list(all_deals)
                memcache.set(key, all_deals)
           return all_deals


    choose_city = self.request.get('c')
    try:
        initial_city = str(choose_city)
        choose_city = initial_city
    except ValueError:
        initial_city = 0
        choose_city = initial_city


    template = jinja_environment.get_template('deal.html')
    self.response.out.write(template.render(initial_city = initial_city, get_deals = get_deals))



    app = webapp2.WSGIApplication([('/', MainPage),
                           ('/deal', DealHandler),
                           ('/content', ContentHandler)],
                          debug=True)

And my html page that is not displaying the results is:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/twitter-bootstrap/twitter-bootstrap-      v2/docs/assets/css/bootstrap.css">
<title>
Deallzz: Chosen City: {{ initial_city }}
</title>
</head>
<body>
All deals:

{% for deal in deals %}
<li>{{ get_deals }}</li>
{% endfor %}

</body>
</html>
  • 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-06-12T06:07:11+00:00Added an answer on June 12, 2026 at 6:07 am
    1. In your code you are not calling get_deals function. I would suggest you to take get_deals() out of get() and call it like

      self.response.out.write(template.render(initial_city = initial_city, get_deals =self.get_deals(choose_city)))
      

      because it is a good design.

      EDIT
      Change self.get_deals() to ‘get_deals()` if you do not plan to do so.

    2. You use deals in your html but is not specifying its value when calling from the server.
      Probably what you want to do is

      {% for deal in get_deals %}    
          {{ deal }}  
      {% endfor %}
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to access camera from a remote html page. I load this html
how to load the other HTML page when i click a button? i'm using
I am using jQuery to load the search results from a php class when
Hi I have a search results page which returns queries form the database using
how can I load an html page inside a div. With the 'object' tag
I created in php starting with file_get_content to load a HTML page, parse to
i have the following code to try and load a local html page in
In our HTML page, we have a list of tags to load in many
Whenever I load ONLY the 1.3 or 1.4 library on an html page im
I have a overlay delay on my html page, if the page couldnt load

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.