views:

28

answers:

2

I have two methods defined in views.py. the first one calls the second one:

@login_required 
def form1(request):
    if request.method == 'POST':
        form = JobForm(request.POST)
        if form.is_valid():
          obj = form.save(commit=False)
          obj.user = request.user
          obj.save()
          return HttpResponseRedirect(job)
    else:
        return render_to_response('sync_form.html', {'form': form})

def job(request):   #I get the error right here
    cmd = '/root/test.sh'
    p = Popen(cmd, shell=True, stdout=PIPE)
    in_progress = p.communicate()
    return render_to_response('job.html', {'in_progress': in_progress})

I get 'Invalid Syntax' where I define the second method. Can someone help me out? Thanks in advance.

A: 

You're trying to pass a rendered template as a HttpResponseRedirect argument, which will break things.

Change:

return HttpResponseRedirect(job)

to:

return job(request)

And that may well sort it.

stevejalim
Thank you so much sir. This solved it as well as other problems that arised.
Ping Pengũin
You're welcome. Could you please accept my answer, by clicking the white tick to the left?
stevejalim
A: 

Most probably a indentation error. Search and replace all tabs by 4 spaces then checks for inconsistencies in indentation.

e-satis