本文承接《用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,如需转载请自行联系原作者