Re: The view didn't return an HttpResponse object.
On Mon, Oct 1, 2012 at 4:58 PM, Babatunde Akinyanmi wrote: > Oooops. I see the question has already been answered. My phone didn't > get the update on time. No worries, Thanks anyways > On 10/1/12, Babatunde Akinyanmi wrote: >> Its possible that when you refresh the form and the POST request gets >> submitted, the form doesn't pass the form.is_valid() if conditional. >> In your code, you didn't make any provision for when the form fails >> the is_valid() test and from your code, execution stops once >> is_valid() returns False so I **guess** that's where the problem lies. >> >> Try re-rendering the submitted form if is_valid is False or doing a >> redirect. >> >> On 10/1/12, Satinderpal Singh wrote: >>> I made a model form and a view which accepts input as a form and >>> display it in the html format. As when i refresh the html page or try >>> to fill another entry in the form, it gives the following error: >>> >>> The view Automation.report.views.chemical_analysis didn't return an >>> HttpResponse object. >>> >>> Here is the views that creates this problem: >>> def chemical_analysis(request): >>> if request.method=='POST': >>> form = chem_analysisForm(request.POST) >>> if form.is_valid(): >>> cd = form.cleaned_data >>> form.save() >>> chem = chem_analysis.objects.all() >>> #return HttpResponseRedirect(chem) >>> return >>> render_to_response('report/chemical_analysis.html', >>> {'chem': chem,},context_instance=RequestContext(request)) >>> >>> else: >>> form = chem_analysisForm() >>> return render_to_response('report/report.html', >>> {"form":form}, >>> context_instance=RequestContext(request)) >>> >>> Any help regarding this will be highly appreciated. >>> >>> -- >>> Satinderpal Singh >>> http://satindergoraya.blogspot.in/ >>> http://satindergoraya91.blogspot.in/ >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >>> >> >> -- >> Sent from my mobile device >> > > -- > Sent from my mobile device > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Satinderpal Singh http://satindergoraya.blogspot.in/ http://satindergoraya91.blogspot.in/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
Oooops. I see the question has already been answered. My phone didn't get the update on time. On 10/1/12, Babatunde Akinyanmi wrote: > Its possible that when you refresh the form and the POST request gets > submitted, the form doesn't pass the form.is_valid() if conditional. > In your code, you didn't make any provision for when the form fails > the is_valid() test and from your code, execution stops once > is_valid() returns False so I **guess** that's where the problem lies. > > Try re-rendering the submitted form if is_valid is False or doing a > redirect. > > On 10/1/12, Satinderpal Singh wrote: >> I made a model form and a view which accepts input as a form and >> display it in the html format. As when i refresh the html page or try >> to fill another entry in the form, it gives the following error: >> >> The view Automation.report.views.chemical_analysis didn't return an >> HttpResponse object. >> >> Here is the views that creates this problem: >> def chemical_analysis(request): >> if request.method=='POST': >> form = chem_analysisForm(request.POST) >> if form.is_valid(): >> cd = form.cleaned_data >> form.save() >> chem = chem_analysis.objects.all() >> #return HttpResponseRedirect(chem) >> return >> render_to_response('report/chemical_analysis.html', >> {'chem': chem,},context_instance=RequestContext(request)) >> >> else: >> form = chem_analysisForm() >> return render_to_response('report/report.html', >> {"form":form}, >> context_instance=RequestContext(request)) >> >> Any help regarding this will be highly appreciated. >> >> -- >> Satinderpal Singh >> http://satindergoraya.blogspot.in/ >> http://satindergoraya91.blogspot.in/ >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to django-users@googlegroups.com. >> To unsubscribe from this group, send email to >> django-users+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> >> > > -- > Sent from my mobile device > -- Sent from my mobile device -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
Its possible that when you refresh the form and the POST request gets submitted, the form doesn't pass the form.is_valid() if conditional. In your code, you didn't make any provision for when the form fails the is_valid() test and from your code, execution stops once is_valid() returns False so I **guess** that's where the problem lies. Try re-rendering the submitted form if is_valid is False or doing a redirect. On 10/1/12, Satinderpal Singh wrote: > I made a model form and a view which accepts input as a form and > display it in the html format. As when i refresh the html page or try > to fill another entry in the form, it gives the following error: > > The view Automation.report.views.chemical_analysis didn't return an > HttpResponse object. > > Here is the views that creates this problem: > def chemical_analysis(request): > if request.method=='POST': > form = chem_analysisForm(request.POST) > if form.is_valid(): > cd = form.cleaned_data > form.save() > chem = chem_analysis.objects.all() > #return HttpResponseRedirect(chem) > return > render_to_response('report/chemical_analysis.html', > {'chem': chem,},context_instance=RequestContext(request)) > > else: > form = chem_analysisForm() > return render_to_response('report/report.html', > {"form":form}, > context_instance=RequestContext(request)) > > Any help regarding this will be highly appreciated. > > -- > Satinderpal Singh > http://satindergoraya.blogspot.in/ > http://satindergoraya91.blogspot.in/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Sent from my mobile device -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
On Mon, Oct 1, 2012 at 12:11 PM, Satinderpal Singh wrote: > On Mon, Oct 1, 2012 at 4:27 PM, Tom Evans wrote: >> On Mon, Oct 1, 2012 at 11:36 AM, Satinderpal Singh >> wrote: > I add the following to my code, >>> I made a model form and a view which accepts input as a form and >>> display it in the html format. As when i refresh the html page or try >>> to fill another entry in the form, it gives the following error: >>> >>> The view Automation.report.views.chemical_analysis didn't return an >>> HttpResponse object. >>> >>> Here is the views that creates this problem: >>> def chemical_analysis(request): >>> if request.method=='POST': >>> form = chem_analysisForm(request.POST) >>> if form.is_valid(): >>> cd = form.cleaned_data >>> form.save() >>> chem = chem_analysis.objects.all() >>> #return HttpResponseRedirect(chem) >>> return >>> render_to_response('report/chemical_analysis.html', >>> {'chem': chem,},context_instance=RequestContext(request)) > else: > return HttpResponse("There was an error with > your > submission. Please try again.") >>> >>> else: >>> form = chem_analysisForm() >>> return render_to_response('report/report.html', >>> {"form":form}, >>> context_instance=RequestContext(request)) >>> >>> Any help regarding this will be highly appreciated. >>> >> >> If the request method is POST, but the form is not valid, then no >> response is returned. You must return a response from every code path. > Thanks, it works and now gives the error message, can you please tell > me that why the input values are not saved in the database and it > gives only the error message. Point me where i am wrong. > The form is not valid; check the data you are submitting and the form definition to see why. The invalid form object itself will specify why it is invalid, see the docs: https://docs.djangoproject.com/en/1.4/topics/forms/#using-a-form-in-a-view https://docs.djangoproject.com/en/1.4/ref/forms/api/#using-forms-to-validate-data Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
On Mon, Oct 1, 2012 at 4:27 PM, Tom Evans wrote: > On Mon, Oct 1, 2012 at 11:36 AM, Satinderpal Singh > wrote: I add the following to my code, >> I made a model form and a view which accepts input as a form and >> display it in the html format. As when i refresh the html page or try >> to fill another entry in the form, it gives the following error: >> >> The view Automation.report.views.chemical_analysis didn't return an >> HttpResponse object. >> >> Here is the views that creates this problem: >> def chemical_analysis(request): >> if request.method=='POST': >> form = chem_analysisForm(request.POST) >> if form.is_valid(): >> cd = form.cleaned_data >> form.save() >> chem = chem_analysis.objects.all() >> #return HttpResponseRedirect(chem) >> return >> render_to_response('report/chemical_analysis.html', >> {'chem': chem,},context_instance=RequestContext(request)) else: return HttpResponse("There was an error with your submission. Please try again.") >> >> else: >> form = chem_analysisForm() >> return render_to_response('report/report.html', >> {"form":form}, >> context_instance=RequestContext(request)) >> >> Any help regarding this will be highly appreciated. >> > > If the request method is POST, but the form is not valid, then no > response is returned. You must return a response from every code path. Thanks, it works and now gives the error message, can you please tell me that why the input values are not saved in the database and it gives only the error message. Point me where i am wrong. -- Satinderpal Singh http://satindergoraya.blogspot.in/ http://satindergoraya91.blogspot.in/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
On Mon, Oct 1, 2012 at 11:36 AM, Satinderpal Singh wrote: > I made a model form and a view which accepts input as a form and > display it in the html format. As when i refresh the html page or try > to fill another entry in the form, it gives the following error: > > The view Automation.report.views.chemical_analysis didn't return an > HttpResponse object. > > Here is the views that creates this problem: > def chemical_analysis(request): > if request.method=='POST': > form = chem_analysisForm(request.POST) > if form.is_valid(): > cd = form.cleaned_data > form.save() > chem = chem_analysis.objects.all() > #return HttpResponseRedirect(chem) > return > render_to_response('report/chemical_analysis.html', > {'chem': chem,},context_instance=RequestContext(request)) > > else: > form = chem_analysisForm() > return render_to_response('report/report.html', > {"form":form}, > context_instance=RequestContext(request)) > > Any help regarding this will be highly appreciated. > If the request method is POST, but the form is not valid, then no response is returned. You must return a response from every code path. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
The view didn't return an HttpResponse object.
I made a model form and a view which accepts input as a form and display it in the html format. As when i refresh the html page or try to fill another entry in the form, it gives the following error: The view Automation.report.views.chemical_analysis didn't return an HttpResponse object. Here is the views that creates this problem: def chemical_analysis(request): if request.method=='POST': form = chem_analysisForm(request.POST) if form.is_valid(): cd = form.cleaned_data form.save() chem = chem_analysis.objects.all() #return HttpResponseRedirect(chem) return render_to_response('report/chemical_analysis.html', {'chem': chem,},context_instance=RequestContext(request)) else: form = chem_analysisForm() return render_to_response('report/report.html', {"form":form}, context_instance=RequestContext(request)) Any help regarding this will be highly appreciated. -- Satinderpal Singh http://satindergoraya.blogspot.in/ http://satindergoraya91.blogspot.in/ -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: The view didn't return an HttpResponse object.
On Tue, 2008-12-16 at 23:23 -0800, oops wrote: > def OrderPlacedView(request): > form = OrderPlaceForm() > try: > print "try" > print request.POST > #brand = BrandName.objects.get(pk=request.POST['brand']) > except: > print"nothing" > return render_to_response('inventory/orderprocess.html', > {'form':form}) > > above is my view code when a try to call this view its give and error > "The view didn't return an HttpResponse object." > > i have similar type of view which works fine whats the problem with > this .. Well, the error message is giving you a very big clue. When you see that, look for all the ways that you are exiting that function. In this case, what happens when no exception is raised? At a guess, you have added the wrong indentation on the last line. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: The view didn't return an HttpResponse object.
On Dec 17, 2008, at 3:23 PM, oops wrote: > > def OrderPlacedView(request): >form = OrderPlaceForm() >try: >print "try" >print request.POST >#brand = BrandName.objects.get(pk=request.POST['brand']) >except: >print"nothing" >return render_to_response('inventory/orderprocess.html', > {'form':form}) This return statement is indented to be inside the except clause. If no exception is raised, the view doesn't return anything... Yours, Eric > > > above is my view code when a try to call this view its give and error > "The view didn't return an HttpResponse object." > > i have similar type of view which works fine whats the problem with > this .. > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
The view didn't return an HttpResponse object.
def OrderPlacedView(request): form = OrderPlaceForm() try: print "try" print request.POST #brand = BrandName.objects.get(pk=request.POST['brand']) except: print"nothing" return render_to_response('inventory/orderprocess.html', {'form':form}) above is my view code when a try to call this view its give and error "The view didn't return an HttpResponse object." i have similar type of view which works fine whats the problem with this .. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---