时间:2014年12月03日 12:53:44点击:1235类别:解决方案
一个典型的例子作分析:
以本站为例,首页中我要链接至showreply/id/。
在url.py中定义:
url(r'^MyBlog/showreply/(\d+)/',showreply),
在view.py中定义函数:
def showreply(request,rid): global localip posts=BlogPost.objects.all rposts=ReplyPost.objects.all return render_to_response('show.html',{'posts': posts,'rposts':rposts,'localip':localip,},context_instance=RequestContext(request))
rid就是我们要取的id参数,我们在url中使用(\d+)进行正则的结果。
可以直接在函数中调用!
学习了!
坤坤大神
2014-12-03
睡觉了!
楼主ヾ(。`Д´。)
喜欢:(1235) 回复:(3)
以下为回复内容
1#楼的helen007于2014年12月04日 03:30:12回复道:
楼主很厉害的样子
2#楼的helen007于2014年12月05日 03:28:05回复道:
楼上的认识坤坤大神吗?据说很神秘的,资深程序员,这个网站就是他做的
3#楼的ヾ(。`Д´。)于2014年12月05日 09:39:39回复道:
不认识!你跟他很熟吗?