📌  相关文章
📜  django 仅返回字符串的一部分 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:38.588000             🧑  作者: Mango

代码示例1
{{ model.field|truncatewords:30 }}
# Example below returns just the first 30 words of the text_summary column 
# (for each line/book in the books table)
    {% for book in books.all %}
  • {{ book.text_summary|truncatewords:30 }}
  • {% endfor %}