1.

(r’^articles/(\d{4})/(\d{2})/$’, month_archive)

vs.

2.

(r’^articles/(?P<year>\d{4})/(?P<month>\d{2})/$’, month_archive)

The first one: positional argument

The second one: keyword argument

For example, a request to

/articles/2009/10/

would result in

1. month_archive (request, ’2009′,’10′)

2. month_archive(request, year=’2009′, month=’10′)

in urls.py

r(‘^card/(?P<year>\d{4})/(?P<month>\w{3})(?P<day>\d{2})/(?P<slug>[-\w]+)/$’, ‘card_detail’),

in views.py

def card_detail(request, year, month, day, slug):

# do render

————-

will return dictionary with keys are bracketed names and the values are the parts of the text that matched.

© 2011 Web Oom Suffusion theme by Sayontan Sinha
Switch to our mobile site
Top Footer