0
我想知道是否有必要在我的urls.py這兩個模式:我可以合併這兩種網址格式嗎?
url(r'^books/author/(?P<id>\d+)/$', 'books.views.author'),
url(r'^books/author/(?P<id>\d+)/(?P<slug>[-\w]+)/$', 'books.views.author'),
基本上,蛞蝓是可選的。而查看功能的定義是這樣的:
def author(request, id, slug=None):
請指教。