我目前使用的是Django 1.5,並且無法弄清楚如何顯示一個簡單的html頁面。我一直在閱讀基於類的視圖,但我不確定這是我想要做的。顯示簡單的html頁面Django
我想展示一個簡單的index.html頁面,但根據一些示例,我已經看到了,我需要把這個代碼在app/views.py:
def index(request):
template = loader.get_template("app/index.html")
return HttpResponse(template.render)
是否有一個原因爲什麼我的index.html頁面必須與我的django項目關聯的應用程序關聯?對我來說,讓index.html頁面對應整個項目似乎更有意義。
更重要的是,在我的views.py文件中使用此代碼,我需要將什麼放入我的urls.py才能真正實現index.html?
編輯:
webapp/
myapp/
__init__.py
models.py
tests.py
views.py
manage.py
project/
__init__.py
settings.py
templates/
index.html
urls.py
wsgi.py
讀django教程會更有幫助。 – Rohan 2013-03-28 04:34:23