python - Django中文摘要字数怎么控制?
ringa_lee
ringa_lee 2017-04-18 09:55:54
0
1
366

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

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

ringa_lee
ringa_lee

ringa_lee

reply all (1)
阿神

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]

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!