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

  • Home
  • SEARCH
  • 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 340489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:37:15+00:00 2026-05-12T10:37:15+00:00

I am sending an AJAX request to a Django view that can potentially take

  • 0

I am sending an AJAX request to a Django view that can potentially take a lot of time. It goes through some well-defined steps, however, so I would like to print status indicators to the user letting it know when it is finished doing a certain thing and has moved on to the next.

If I was using PHP it might look like this, using the flush function:

do_something();
print 'Done doing something!';
flush();

do_something_else();
print 'Done doing something else!';
flush();

How would I go about doing the same with Django? Looking at the documentation I see that HttpResponse objects have a flush method, but all it has to say is that “This method makes an HttpResponse instance a file-like object.” – I’m not sure that’s what I want. I’m having a hard time wrapping my head around how this could be done in Django since I have to return the response and don’t really have a control of when the content goes to the browser.

  • 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-12T10:37:15+00:00Added an answer on May 12, 2026 at 10:37 am

    Most webservers (eg. FCGI/SCGI) do their own buffering, HTTP clients do their own, and so on. It’s very difficult to actually get data flushed out in this way and for the client to actually receive it, because it’s not a typical operation.

    The closest to what you’re trying to do would be to pass an iterator to HttpResponse, and to do the work in a generator; something like this:

    def index(request):
        def do_work():
            step_1()
            yield "step 1 complete"
            step_2()
            yield "step 2 complete"
            step_3()
            yield "step 3 complete"
        return HttpResponse(do_work())
    

    … but this won’t necessarily flush. (Not tested code, but you get the idea; see http://docs.djangoproject.com/en/dev/ref/request-response/#passing-iterators.)

    Most of the infrastructure is simply not expecting a piecemeal response. Even if Django isn’t buffering, your front-end server might be, and the client probably is, too. That’s why most things use pull updates for this: a separate interface to query the status of a long-running request.

    (I’d like to be able to do reliable push updates for this sort of thing, too…)

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

Sidebar

Related Questions

I've got jquery sending an AJAX request that executes some checks and then should
I have written some jQuery ajax code where I am sending a request to
Well it's not realy causing any errors. Anyways i'm sending ajax request and getting
I am sending an Ajax Request using jQuery. What happens is that I am
I'm sending an ajax request that will either give me an error or a
I'm sending an AJAX request and posting some json data to the server. How
I have an ajax request sending some data to a php file: Ext.Ajax.request({ url:
I sending ajax request from a jQuery file like below, which expects response in
I'm sending ajax request and i have appended the result on a div. After
I am sending an ajax request which is called on change event of a

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.