2012-01-09 64 views
1

我試圖在mod_wsgi和Apache的Ubuntu 10服務器上部署一個構建在Django上的應用程序。 當我嘗試訪問某些視圖時,我得到一個200響應,沒有來自服務器的內容。這些是工作和不工作的意見:在Apache上運行的Django應用程序提供空白200響應

def this_works(request): 
    return render_to_response('admin/index.html') 

def this_also_works(request): 
    return HttpResponse(loader.render_to_string('admin/index.html')) 

def this_doesnt_work(request): 
    return SimpleTemplateResponse(Template('Example text')) 

除此之外,管理網站和登錄視圖也不起作用。 該應用程序與Django的runserver完美配合。

我非常感謝任何幫助。在documentation

+0

如果您尚未嘗試交換'this_doesnt_work()'和'this_works()'。我懷疑這個問題可能與你的apache或wsgi配置有關,而不是你的Django代碼,所以如果你交換了函數的內容並點擊了應該工作的函數,你可以縮小這個問題的範圍。 –

回答

0

看你好像正在使用SimpleTemplateResponse錯誤。

return SimpleTemplateResponse(request, 'admin/index.html') 

會按照我看到的方式使用它。如果你想呈現字符串,你會渲染它的視圖,並使用HttpResponse返回它。

相關問題