我是正则表达式和金字塔的新手,我在DJango中有以下网址,我需要将其翻译为金字塔:
varchar(100)
我在文档中看到你有类似的东西:
DOWNLOAD_XFORM = "download_xform"
LIST_XFORMS = "list_xforms"
FORM_LIST = "form_list"
OPT_GROUP_REGEX = "((?P<group_name>[^/]+)/)?"
urlpatterns = patterns('',
url(r"^%sformList$" % OPT_GROUP_REGEX, views.formList, name=FORM_LIST),
url(r"^%ssubmission$" % OPT_GROUP_REGEX, views.submission),
url(r"^%sxform/new/$" % OPT_GROUP_REGEX, views.create_xform),
url(r"^%sxform/(?P<id_string>[^/]+)\.xml$" % OPT_GROUP_REGEX, views.download_xform, name=DOWNLOAD_XFORM),
url(r"^xform/toggle_downloadable/(?P<id_string>[^/]+)/$", views.toggle_downloadable),
url(r"^submission_test_form/?$", views.submission_test_form),
url(r"^xform/(?P<id_string>[^/]+)/$", views.update_xform),
url(r"^%s$" % OPT_GROUP_REGEX, views.list_xforms, name=LIST_XFORMS),
url(r"^survey/(?P<pk>\d+)/$", views.instance),)
但我无法迁移像:
这样的位config.add_route('myroute', '/prefix/{foo:[^/]+}')
任何想法都将不胜感激
答案 0 :(得分:0)
不太了解迁移。但对于数字网址调度正则表达式,您可以使用
config.add_route('home', '/{number_id:\d+}')
*来自文档