肥嘟嘟(Fatbobman)的学习笔记Rss Feed

上学的时候懒不愿意做笔记,但确实了解笔记的重要性。现在想做笔记了,但是还是懒,当然对于重要性的认识丝毫没有动摇。

2005/11/29

Django 提供了非关键字的url map方式

http://www.djangoproject.com/documentation/url_dispatch

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^articles/2003/$', 'news.views.special_case_2003'),
(r'^articles/(\d{4})/$', 'news.views.year_archive'),
(r'^articles/(\d{4})/(\d{2})/$', 'news.views.month_archive'),
(r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article_detail'),
)

由于没有关键字,因此所获得的参数是按顺序调用
类似:news.views.month_archive(request, '2005', '03')
个人所好不同吧。总之django一直在努力!

0 Comments:

发表评论

<< Home