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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:22:22+00:00 2026-05-15T00:22:22+00:00

I am developing a microblogging platform in which I need to populate the page

  • 0

I am developing a microblogging platform in which I need to populate the page with Post (user defined class with fields) obtained from the Django server using HttpGet.

In the client side(Android) I am using GSON to parse the responses from server to the type Post. So I require that server should send Post’s one by one so as to add each of them to a list of Posts after parsing and then finally notifying the list adapter of changes in the data set after all Post’s have been added.

But the problem coming when intially loading the application, the page has to be populated with 10 latest Post’s from the server. So I thought of a rather dirty way of sending 10 httpget requests to the server one after the other to the server. The code looks like this

public void populateTimeline(){
Thread populate = new Thread(){
    public void run(){
        Looper.prepare();
        InputStream data = getData(serviceURL);  //gets a post from server
        if(data!= null){
            String result = responsetoString(data); //turns response to String
            progressDialog.show();
            Posts post = toPostfromGson(result); //Parses string to Post Object             
        }
        Looper.loop();
    }

};
populate.start();       

}

I was thinking of executing it 10 times in a loop to get the 10 Post’s I require. But in Django as far I know (correct me if I am wrong) there’s no way to keep an index of the last sent Post to the client and so no way to send the ‘next’ Post on the next HttpGet request. So I am out of ideas.

I feel there’s a better way to do this efficiently. Any help would be much appreciated.

  • 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-15T00:22:23+00:00Added an answer on May 15, 2026 at 12:22 am

    As an elaboration on Dmitry’s comment, consider adding a view in your Django app which returns multiple (serialized) Posts. Something like the following:

    def get_posts(request, count=10):
        posts = Post.objects.all().order_by("-date")[:count]
        posts_in_gson = serialize_to_gson(posts)
        return HttpResponse(posts_in_gson)
    

    Your client code will need to handle a list of posts as well as a single post. (Or just make subsequent calls with count=1.)

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

Sidebar

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.