有什么方法可以简化模式<product>
而不将它们放在单独的文件中?
urlpatterns = patterns('',
# Basic product functions
url(r'^create/$', 'product.views.create'),
url(r'^save/$', 'product.views.save'),
url(r'^save/(?P<product>[a-z0-9\-]+)/$', 'product.views.save'),
url(r'^edit/(?P<product>[a-z0-9\-]+)/$', 'product.views.edit'),
url(r'^publish/(?P<product>[a-z0-9\-]+)/$', 'product.views.publish'),
url(r'^upload_image/(?P<product>[a-z0-9\-]+)/$', 'product.views.upload_image'),
# Blog
url(r'^(?P<product>[a-z0-9\-]+)/blog/(?P<blog_id>[0-9]+)/view/(?P<content_id>[0-9]+)/$', 'blog.views.view'),
url(r'^(?P<product>[a-z0-9\-]+)/blog/(?P<blog_id>[0-9]+)/$', 'blog.views.main'),
url(r'^(?P<product>[a-z0-9\-]+)/blog/(?P<blog_id>[0-9]+)/(?P<page>[0-9]+)/$', 'blog.views.main'), #pagination for main
# Categories
url(r'^(?P<product>[a-z0-9\-]+)/category/(?P<category_id>[0-9]+)/$', 'category.views.category'),
url(r'^(?P<product>[a-z0-9\-]+)/category/(?P<blog_id>[0-9]+)/category/(?P<category_id>[0-9]+)/(?P<page>[0-9]+)/$', 'category.views.category'), #pagination for main
# Content
url(r'^(?P<product>[a-z0-9\-]+)/content/(?P<blog_id>[0-9]+)/edit/$', 'content.views.edit'),
url(r'^(?P<product>[a-z0-9\-]+)/content/(?P<blog_id>[0-9]+)/edit/(?P<content_id>[0-9]+)/$', 'content.views.edit'),
)
只是寻找任何可能的方法来简化这里的东西。
有没有某种包装器我可以把所有的^<product>
模式都放在里面来预处理它?