use slugify in template

前端 未结 2 1209

I want to have SEO-friendly URL,my current url in urls.py :

(ur\'^company/news/(?P.*)/(?P\\d+)/$\',\'C         


        
2条回答
  •  隐瞒了意图╮
    2021-02-13 10:09

    Have you tried n.title|slugify and see if that works for you.

    ref: https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#slugify

    Note: although this is possible, just make sure the 'slugified' element is never used for any part of routing... (ie, purely for display only)

提交回复
热议问题