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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:30:52+00:00 2026-06-14T15:30:52+00:00

I have a web page that’s being served records from the DB to a

  • 0

I have a web page that’s being served records from the DB to a Django html template in Google App Engine. Is it possible to do this loading of posts asynchronously, like when a user scrolls down 10 posts on the page, it loads another 10? Should i do this in the template with some kind of jQuery or is it an asynchronous DB fetch?

class MainHandler(webapp2.RequestHandler):
    def get(self):
        records_query = db.GqlQuery("SELECT * FROM Record order by date desc")
        records = records_query.fetch(10)
        self.response.out.write(records_query)
        template_values = {
           'records': records,
        }
        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))

class Page(webapp2.RequestHandler):
     def get(self,page):
        numberOfPages = int(page)
        records_query = db.GqlQuery("SELECT * FROM Record order by date desc")
        records = records_query.fetch(numberOfPages * 10)
        records = records[((numberOfPages- 1) * 10):]
        template_values = {
           'records': records,
        }
        path = os.path.join(os.path.dirname(__file__), 'index.html')
        self.response.out.write(template.render(path, template_values))

In the template its just the ordinary looping through the records sent from DB

{% for record in records %}
{{ record.title }} {{ record.body }}
{% endfor %}
  • 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-14T15:30:53+00:00Added an answer on June 14, 2026 at 3:30 pm

    This is my solution. It now loads asyncrously when you scroll to the bottom. Its based on the second example from this site

    Template.html:

    <div id="postswrapper">
               <div class="item">content</div>
               <div id="loadmoreajaxloader" style="display:none;"><center><img src="ajax-loader.gif" /></center></div>
        </div>
        <script type="text/javascript">
            var pageCounter = 2;
            $(window).scroll(function()
            {
                if (pageCounter > 0)
                {
                    if($(window).scrollTop() == $(document).height() - $(window).height())
                    {
                        $('div#loadmoreajaxloader').show();
                        $.ajax({  url: "./page/" + pageCounter , success: function(html)  {
                                if(html)
                                {
                                    $("#postswrapper").append(html);
                                    $('div#loadmoreajaxloader').hide();
                                    pageCounter++;
                                }else
                                {
                                    pageCounter = -1;
                                    $('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
                                }
                            }
                        });
                        pageCounter = -1;
                    }
                }
            });
        </script>
    

    And this is the method in main,py which loads the posts from DB.

    class Page(webapp2.RequestHandler):
        def get(self,page):
            numberOfPages = int(page)
            records_query = db.GqlQuery("SELECT * FROM Record order by date desc")
            records = records_query.fetch(numberOfPages * 10)
            records = records[((numberOfPages- 1) * 10):]
            if len(records) > 0:
                template_values = {
                 'records': records,
                }
                path = os.path.join(os.path.dirname(__file__), 'posts.html')
                self.response.out.write(template.render(path, template_values))
    

    This is the template thats loaded into the main template.
    posts.html

    <!DOCTYPE html>
    <html>
    <head>
        <title></title>
    </head>
    <body>
    {% for record in records %}
    <div class="oneRecord">
        <img src="{{ record.imageCacheURL }}" />
        <a href ="./{{ record.imageID }}"> {{ record.title|escape }}</a>
    </div>
    {% endfor %}
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web page that is being displaying in a winform app using
I have this web page that begins with <!-- DOCTYPE html --> , which
I have a web page that lists a number of companies from a MYSQL
I have a web page that display this: The Html behind this is: <label>Approved
I have a web page that loads two images from a css sprite like
I have a web page that i have written in mainly HTML. When I
I have a web-page that starts like so: <!DOCTYPE html> <html> <head> <!--[if lt
I have a web page that dynamically generates form HTML via JavaScript and pours
I have a web page that returns over 36000 items from sql server and
I have a web page that I created with html tags(form and table) and

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.