use slugify in template

前端 未结 2 2113
不思量自难忘°
不思量自难忘° 2021-02-13 09:29

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

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


        
2条回答
  •  终归单人心
    2021-02-13 09:55

    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)

提交回复
热议问题