Re: Django + ajax waiting page, can not redirect to result page

2011-12-19 Thread Brett Epps
Change this:

def run_DHM(request):
xx = {'ok':'TRUE'}
#return HttpResponse("OK")
return xx

To this:

def run_DHM(request):
return HttpResponse("{'ok': true}")

You were getting that error because views should always return
HttpResponse objects.


Brett


On 12/16/11 5:18 PM, "yun li"  wrote:

>thanks for Denis' suggestion, I can see errors now. looks like there
>is an AttributeError. here is the error information:
>
>###
>AttributeError at /run_DHM
>
>'dict' object has no attribute 'status_code'
>
>Request Method:GET
>Request URL:   http://127.0.0.1:8000/run_DHM
>Django Version:1.3.1
>Exception Type:AttributeError
>Exception Value:
>
>'dict' object has no attribute 'status_code'
>###
>
>and here are all current codes.
>
>urls.py---
>--
>import mytest.views as views
>from django.shortcuts import render_to_response
>from django.conf.urls.defaults import patterns, include, url
>
># Uncomment the next two lines to enable the admin:
># from django.contrib import admin
># admin.autodiscover()
>
>urlpatterns = patterns('',
>   (r'^test$',views.test_form),
>   (r'^please_wait', views.please_wait),
>   url(r'^run_DHM$', views.run_DHM, name="run_DHM") ,
>   url(r'^displayDHM', views.display_DHM, name="displayDHM")
>)
>
>
>-
>views.py--
>---
>from django.shortcuts import render_to_response
>from django.core.context_processors import csrf
>from django.http import HttpResponse
>
>def test_form(request):
>   c = {}
>   c.update(csrf(request))
>   return render_to_response('test.html',c)
>
>def please_wait(request):
>   return render_to_response('please_wait.html')
>
>def run_DHM(request):
>   xx = {'ok':'TRUE'}
>   #return HttpResponse("OK")
>   return xx
>
>def display_DHM(request):
>   return render_to_response('display_DHM.html')
>
>
>-
>please_wait.html--
>---
>
>
>
>Please wait.
>
>http://code.jquery.com/jquery-1.7.1.min.js";>script>
>