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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:38:29+00:00 2026-06-15T04:38:29+00:00

I want to know how can I stream data to client using django. The

  • 0

I want to know how can I stream data to client using django.

The Goal

The user submits a form, the form data is passed to a web service which returns a string. The string is tarballed (tar.gz) and the tarball is sent back to the user.

I don’t know what’s the way. I searched and I found this, but I just have a string and I don’t know if it is the thing I want, I don’t know what to use in place of filename = __file__ , because I don’t have file – just a string. If I create a new file for each user, this won’t be a good way. so please help me. (sorry I’m new in web programming).

EDIT:

$('#sendButton').click(function(e) {
        e.preventDefault();
        var temp = $("#mainForm").serialize();
        $.ajax({
            type: "POST",
            data: temp,
            url: 'main/',
            success: function(data) {                
                $("#mainDiv").html(data.form);
                ????                

            }
        });
    });

I want to use ajax, so what should i do in success of ajac function and in return of view. really thanks.

my view.py:

def idsBackup(request):
    if request.is_ajax():        
        if request.method == 'POST':
           result = ""
           form = mainForm(request.POST)
           if form.is_valid():
               form = mainForm(request.POST)
               //do form processing and call web service               

                    string_to_return = webserviceString._result 
                    ???
           to_json = {}
           to_json['form'] = render_to_string('main.html', {'form': form}, context_instance=RequestContext(request))
           to_json['result'] = result
           ???return HttpResponse(json.dumps(to_json), mimetype='application/json')
        else:
            form = mainForm()
        return render_to_response('main.html', RequestContext(request, {'form':form}))
    else:
        return render_to_response("ajax.html", {}, context_instance=RequestContext(request))
  • 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-15T04:38:30+00:00Added an answer on June 15, 2026 at 4:38 am

    You can create a django file instance of ContentFile using a string content instead of actual file and then send it as a response.

    Sample code:

    from django.core.files.base import ContentFile
    def your_view(request):
        #your view code
        string_to_return = get_the_string() # get the string you want to return.
        file_to_send = ContentFile(string_to_return)
        response     = HttpResponse(file_to_send,'application/x-gzip')
        response['Content-Length']      = file_to_send.size    
        response['Content-Disposition'] = 'attachment; filename="somefile.tar.gz"'
        return response   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to know how can I read attachment messages without using scriplets in
I want to know can we have a JPanel with a Layout other than
i want know how i can manage multiple twitter account on iOS in my
I want to know how can a retrieve a UIImage size, depending on the
I want to know how can we know the other users of Oracle 10g
I want to know how can I perform VS2008 load test from five different
I want to know how can i fill only certain columns while filling the
I want to know that can mouse click event detects colors or even strings.
I want to know i can do something similar to this (not working) code
I want to know how can i format a number like 2000000 into standard

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.