以下是您在我的django視圖中的2個功能。 第一個和第二個應該做同樣的事情。但是當我使用第一個函數時,它在最後一行說「外部函數」,即「return HttpResponse(output)」。Django查看功能似乎不起作用
這是爲什麼?
感謝, Shiyam
def main_page(request):
output = '''
<html>
<head><title>%s</title></head>
<body>
<h1>%s</h1><p>%s</p>
</body>
</html>
''' % (
'Django Learning',
'Welcome',
'WYou can share book marks here!'
)
return HttpResponse(output)
def main_page(request):
title_sowl = "Django Learning"
header_sowl = "Welcome"
text_sowl = "You can share book marks here"
output = u"<html><head><title>%s</title></head><body><h1>%s</h1><p>%s</p></body></html>" % (title_sowl,header_sowl,text_sowl)
return HttpResponse(output)
您需要縮進(標籤)多一級第一個返回 – 2012-07-27 16:58:45