Home  >  Q&A  >  body text

python - Django中文摘要字数怎么控制?

最近在倒腾个Django的简易blog。期间很多地方需要控制post的显示字数,比如在post_list,feed输出或者其他自定义页面。

turncatewords 似乎仅支持英文,那么,Django中文摘要字数怎么控制呢?求大神指点。

ringa_leeringa_lee2714 days ago398

reply all(1)I'll reply

  • 阿神

    阿神2017-04-18 09:57:54

    You can use slicing to make post_list only display the first few hundred characters. For example, if your content is content, only the first 100 characters will be displayed. content[:100]

    reply
    0
  • Cancelreply