form following another form workflow question

This is the place for queries that don't fit in any of the other categories.

form following another form workflow question

Postby ole111 » Tue Apr 08, 2014 12:31 am

Hello, I am working on my first django webaite, I need to submit two forms one after the other.
Here is the view for the first form:
Code: Select all
def home(request):
  import json
  if request.method == 'POST':
    form = MainForm(request.POST)
    if form.is_valid():
        url = ''
        dataout = {'my':'data'}
        headers = {'content-type':'application/json'}
        r =,data=json.dumps(dataout),headers=headers)
        return collector(request)
    form = MainForm()
  data = {
    'form': form,
  return render(request, 'index.html', data)

From here I call the second view:
Code: Select all
def collector(request):
  if request.method == 'POST':
    form = ContactForm(request.POST)
    return HttpResponse("thanx")               
  return render(request,'contact_form.html')

The problem is that second view never stops at contact_form but displays 'thanx' message. What is the error here, how do I display and submit second form?
thank you.
Posts: 7
Joined: Thu Mar 27, 2014 11:23 pm

Return to General Coding Help

Who is online

Users browsing this forum: Google [Bot] and 12 guests