Change index_view 200 into 20
This commit is contained in:
@@ -34,12 +34,12 @@ def index(request):
|
||||
|
||||
posts = posts.order_by('-publish_date').distinct()
|
||||
|
||||
# 为每篇文章添加摘要(前200个字符)
|
||||
# 为每篇文章添加摘要(前50个字符)
|
||||
for post in posts:
|
||||
# 移除HTML标签并截取前200个字符作为摘要
|
||||
# 移除HTML标签并截取前50个字符作为摘要
|
||||
import re
|
||||
clean_content = re.sub(r'<[^>]+>', '', post.get_markdown_content())
|
||||
post.summary = clean_content[:200] + '...' if len(clean_content) > 200 else clean_content
|
||||
post.summary = clean_content[:50] + '...' if len(clean_content) > 50 else clean_content
|
||||
|
||||
return render(request, 'blog/index.html', {
|
||||
'posts': posts,
|
||||
|
||||
Reference in New Issue
Block a user