本文承接《用django自定義一個網頁》
1.定義視圖函數
vim learn/views.py
def home(request):
return render(request,'home.html')
2.更改url
from django.conf.urls import patterns, include, url
from django.contrib import admin
urlpatterns = patterns('',
# Examples:
url(r'^$', 'learn.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
)
3.在app目錄learn中建立模闆目錄templates目錄
在templates目錄中建立home.html
vim home.html
this is a test
4.啟動django
python manage.py runserver 0.0.0.0:8000
5.通路http://ip:8000
本文轉自 shouhou2581314 51CTO部落格,原文連結:http://blog.51cto.com/thedream/1690229,如需轉載請自行聯系原作者