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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:05:51+00:00 2026-05-16T14:05:51+00:00

I have a view like this: def form1(request): if request.method == ‘POST’: form =

  • 0

I have a view like this:

def form1(request):
    if request.method == 'POST':
        form = SyncJobForm(request.POST)
        if form.is_valid():
        # do something
        in_progress = True
        return render_to_response('form1.html', {'in_progress': in_progress})

I would like to know how to set it to refresh the template after is done with the view process. Like rendering the page after its done:

        in_progress = True
        return render_to_response('form1.html', {'in_progress': in_progress})
        # after its finished
        finished = True
        return render_to_response('form1.html', {'finished': finished})

How can I implement something like this? Thanks in advance.

  • 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-16T14:05:52+00:00Added an answer on May 16, 2026 at 2:05 pm

    You can’t maintain state between page calls on a global basis, so you’ll need to store your data in the database. In addition, a view can’t negotiate anything with the browser after it has returned a page, so you need to split this into multiple views and spawn a separate thread for the job. Here’s a general outline that might help:

    def do_something():
        my_job = Jobs.get(id=blah)
        my_job.in_progress = True
        my_job.save()
    
        # Do some stuff here....
    
        my_job.in_progress = False
        my_job.save()
    
    def step1(request):
        in_progress = Jobs.get(id=blah).in_progress
        if not in_progress:
            if request.method == 'POST':
                form = SyncJobForm(request.POST)
                if form.is_valid():
                    thread.start_new_thread(do_something)
                    return HttpResponseRedirect(step2)
                else:
                    return render_to_response('form.html', 'form': form)
            else:
                form = SyncJobForm()
                return render_to_response('form.html', 'form': form)
         else:
             return HttpResponseRedirect(step2)
    
    def step2(request):
        in_progress = Jobs.get(id=blah).in_progress
        if in_progress:
            return render_to_response('in_progress.html')
        else:
            return HttpResponseRedirect(finished)
    
    def finished(request):
        return render_to_response('finished.html')
    

    Then have your page in_progress.html periodically refresh the page. When the job is completed, you can display a status message in finished.html.

    There are more sophisticated ways to do this (write Javascript to poll the server periodically), but you’re still going to need to write separate views to respond with the appropriate information. In addition, you could use a job management framework like Celery to create and execute jobs, but again you’ll still have to create separate views to handle status information.

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

Sidebar

Related Questions

I have a View that renders something like this: Item 1 and Item 2
In my views.py, i have a snippit of code like this: def clean_post_data(form): for
I have a view like this in my Flex mobile Application: <s:View xmlns:fx=http://ns.adobe.com/mxml/2009 xmlns:s=library://ns.adobe.com/flex/spark
I have a block of code in my view like this: <% @map[value].each do
I have a mvc2 application with a view like this <% using (Ajax.BeginForm(UserApprove, new
I have a view model that looks like this public class ViewModelRound2 { public
I have a View that is basically setup like this: <Grid> <ViewBox> <Grid> <ItemsControl
I have a view with a ComboBox like this <ComboBox Name=cmbPurpose DisplayMemberPath=@value SelectedValuePath=@key ItemsSource={Binding
I have added a UILabel to my view programmatically like this: myLabel = [[UILabel
I have a view model coming from the server as json like this {

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.