四种转换器

urlpatterns = [
# str转换器
    path('hello1/<str:name>/',views.hello1,name='hello1'),
# slug转换器
    path('hello2/<slug:name>/',views.hello2,name='hello2'),
# uuid转换器
    path('hello3/<uuid:name>/', views.hello3, name='hello3'),
# path转换器
    path('hello4/<path:name>/', views.hello4, name='hello4'),
# int转换器
    path('<int:program_id>', views.show_program_id2)
]
# str转换器
def hello1(request,name):
    s = '<h1>str转换器 {0}</h1>'.format(name)
    return HttpResponse(s)

# slug转换器
def hello2(request,name):
    s = '<h1>slug转换器 {0}</h1>'.format(name)
    return HttpResponse(s)

# uuid转换器
def hello3(request,name):
    s = '<h1>uuid转换器 {0}</h1>'.format(name)
    return HttpResponse(s)

# path转换器
def hello4(request,name):
    s = '<h1>path转换器 {0}</h1>'.format(name)
    return HttpResponse(s)

# int转换器
def show_program_id2(request,program_id):
    s = 'int转换器 {0}</h1>'.format(program_id)
    return HttpResponse(s)

django学习心得-路径转换器django学习心得-路径转换器django学习心得-路径转换器
django学习心得-路径转换器

相关文章:

  • 2021-09-05
  • 2021-08-17
  • 2022-02-08
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-01-31
猜你喜欢
  • 2022-12-23
  • 2021-07-19
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-12-17
  • 2022-03-04
相关资源
相似解决方案