Add Support dongfangyaocao

This commit is contained in:
2025-08-11 22:20:19 +08:00
parent 6d80326a4e
commit d9d2ea9d99
11 changed files with 686 additions and 58 deletions

View File

@@ -2,20 +2,22 @@ from django.shortcuts import render, get_object_or_404
from django.core.paginator import Paginator
from .models import Article
def article_list(request):
"""
显示文章列表的视图函数
"""
articles = Article.objects.all().order_by('-created_at')
paginator = Paginator(articles, 20) # 每页显示10篇文章
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)
return render(request, 'core/article_list.html', {
'page_obj': page_obj
})
def article_detail(request, article_id):
"""
显示文章详情的视图函数
@@ -24,5 +26,3 @@ def article_detail(request, article_id):
return render(request, 'core/article_detail.html', {
'article': article
})
# Create your views here.