django模板

本文承接《用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


你可能感兴趣的:(django)