jdero
jdero

Reputation: 1817

How do I make my django app load content as I scroll?

I'm sure this problem has multiple solutions. I am currently designing a web application to feature an interface similar to what you would see in a Facebook Activity Stream, in terms of how the content loads.


I want the page to:

Load a given number of objects initially

Load the next set of objects once the user reaches the object at the bottom of the screen, AKA when object, say, 15, becomes visible onscreen, I want to load 15 more objects, and do the same when object 30 appears etc.


I have, in my database, potentially hundreds of thousands of these entries, and I want to make sure the user only has to load a given number at a time to reduce stress on the servers etc.

Since I'm using Django, I figured this would be some really cool JS mixed with django-template language, but I'm not really sure.

Is this more of a CSS problem?

Where do I start in thinking of this? What technologies should I consider? Are there any well known modules I can take advantage of here?

Thanks for your time.

Upvotes: 0

Views: 1786

Answers (1)

Hieu Nguyen
Hieu Nguyen

Reputation: 8623

I take it as you are confident in your Django skill.

If you want to do yourself, then jQuery and jQuery.ajax are 2 things you need to read carefully. Basically you need to check with jQuery if the user scroll to the end of the page, then make ajax call to Django to fetch new data and append to bottom of the page.

If you want to use a ready made package, I think Django endless pagination will do the job.

Upvotes: 3

Related Questions