django notes 5 urlconfig

来源:互联网 发布:d3.js 地图热力图 编辑:程序博客网 时间:2024/04/29 06:12

first import urs ,include patterns (匹配正则)

 

from django.conf.urls.defaults import patterns,include,url

1.

  url(r'^blog/index/$','blog/views/index')


 

2.

from blog.views import indexurl(r'^blog/index/$',index)


 

3.

from blog.views import indexurl(r'^blog/index/$',index)


 

-------------------------------------------------

url pass the arguments

 

url(r'^blog/index/(?P<id>\d{2})/$','index')

then in the views function define way:

def index(req,id)    render_to_response('index.html',{'id':id})

rember the P<id> should be equals with the function 'index()' secend argument

0 0
原创粉丝点击