【问题标题】:Decode url(r'^(?P<pk>[-\w]+)/$') to path() in Django在 Django 中将 url(r'^(?P<pk>[-\w]+)/$') 解码为 path()
【发布时间】:2018-10-08 03:56:39
【问题描述】:

我需要将下面的正则表达式使用 url() 方法转换为 path() 方法。

url(r'^(?P<pk>[-\w]+)/$')

感谢和问候。

【问题讨论】:

  • path('&lt;slug:pk&gt;/')
  • 非常相关的问题!!向上

标签: regex django python-3.x django-2.0


【解决方案1】:

尝试其中一种模式

path('<int:pk>/')
# or 
path('<slug:pk>/')

【讨论】:

    猜你喜欢
    • 2017-01-21
    • 2022-09-29
    • 2011-06-20
    • 2019-08-26
    • 2014-12-16
    • 2018-09-17
    • 1970-01-01
    • 2014-07-12
    • 2018-04-25
    相关资源
    最近更新 更多