2013-05-09 54 views
-1

我有一個函數在我的views.py打印一個字符串。我已經通過django運行本地服務器。 我寫了這段代碼。這個項目的頁面必須顯示單詞「hello world」,但它不是! 你能幫我解決嗎?如何將python代碼連接到服務器?

from django.conf.urls.defaults import * 
from mysite.views import hello 

# Uncomment the next two lines to enable the admin: 
# from django.contrib import admin 
# admin.autodiscover() 

urlpatterns = patterns('', 
    ('^hello/$', hello), 
# Examples: 
# url(r'^$', 'mysite.views.home', name='home'), 
# url(r'^mysite/', include('mysite.foo.urls')), 

# Uncomment the admin/doc line below to enable admin documentation: 
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), 

# Uncomment the next line to enable the admin: 
# url(r'^admin/', include(admin.site.urls)), 
) 
+0

這只是URL路徑啓用更詳細的調試。我們無法看到任何返回「hello world」或正在生成的錯誤消息的代碼。 – Ewan 2013-05-09 14:11:16

+0

這是我views.py內容:從django.http進口的HttpResponse 高清你好(請求): \t返回的HttpResponse(「世界你好」) – 2013-05-09 14:21:18

+0

什麼是錯誤您收到? – Ewan 2013-05-09 14:40:49

回答

0

通過你有什麼判斷和接收404沒有找到我相信你只是要localhost:8000

但是您的網址設置說,你應該去localhost:8000/hello/(你有沒有網頁的索引模式集url(r'^$', hello)

您還需要在您的URL中使用正確的語法。您目前有:

('^hello/$', hello), 

你需要有:

url(r'^hello/$', hello), 

您也可以將您的settings.py文件和設置DEBUG = True