여기 내 장고보기에서 두 가지 기능이 있습니다. 첫 번째와 두 번째는 동일한 작업을 수행해야합니다. 하지만 첫 번째 함수를 사용했을 때 "return HttpResponse (output)"이라는 마지막 줄에 "outside function"이라고 표시됩니다.장고보기 기능이 작동하지 않는 것 같습니다
왜 그럴까요? 당신이이 main_page
방법의 일부로 간주하기 위해서는 그 줄을 들여해야하기 때문에
감사합니다, 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)
첫 번째 리턴 레벨을 한 칸 더 들여 쓰기 (탭)해야합니다. –