Update urls.py

master
p36kxhw2t 1 month ago
parent e90e154590
commit bd4ef294a8

@ -1,62 +1,62 @@
from django.urls import path
from django.views.decorators.cache import cache_page
from django.urls import path #ZNY 导入Django URL路径模块
from django.views.decorators.cache import cache_page #ZNY 导入缓存页面装饰器
from . import views
from . import views #ZNY 导入当前应用的视图模块
app_name = "blog"
urlpatterns = [
path(
app_name = "blog" #ZNY 定义应用命名空间为blog
urlpatterns = [ #ZNY 定义URL模式列表
path( #ZNY 首页路由
r'',
views.IndexView.as_view(),
name='index'),
path(
r'page/<int:page>/',
views.IndexView.as_view(),
name='index_page'),
path(
r'article/<int:year>/<int:month>/<int:day>/<int:article_id>.html',
views.ArticleDetailView.as_view(),
name='detailbyid'),
path(
r'category/<slug:category_name>.html',
views.CategoryDetailView.as_view(),
name='category_detail'),
path(
r'category/<slug:category_name>/<int:page>.html',
views.CategoryDetailView.as_view(),
name='category_detail_page'),
path(
r'author/<author_name>.html',
views.AuthorDetailView.as_view(),
name='author_detail'),
path(
r'author/<author_name>/<int:page>.html',
views.AuthorDetailView.as_view(),
name='author_detail_page'),
path(
r'tag/<slug:tag_name>.html',
views.TagDetailView.as_view(),
name='tag_detail'),
path(
r'tag/<slug:tag_name>/<int:page>.html',
views.TagDetailView.as_view(),
name='tag_detail_page'),
path(
views.IndexView.as_view(), #ZNY 使用类视图处理首页
name='index'), #ZNY URL名称为index
path( #ZNY 首页分页路由
r'page/<int:page>/', #ZNY 带页码参数的URL
views.IndexView.as_view(), #ZNY 使用相同的类视图处理分页
name='index_page'), #ZNY URL名称为index_page
path( #ZNY 文章详情页路由
r'article/<int:year>/<int:month>/<int:day>/<int:article_id>.html', #ZNY 包含年月日和文章ID的URL
views.ArticleDetailView.as_view(), #ZNY 使用文章详情类视图
name='detailbyid'), #ZNY URL名称为detailbyid
path( #ZNY 分类详情页路由
r'category/<slug:category_name>.html', #ZNY 包含分类名称的URL
views.CategoryDetailView.as_view(), #ZNY 使用分类详情类视图
name='category_detail'), #ZNY URL名称为category_detail
path( #ZNY 分类分页路由
r'category/<slug:category_name>/<int:page>.html', #ZNY 包含分类名称和页码的URL
views.CategoryDetailView.as_view(), #ZNY 使用相同的类视图处理分页
name='category_detail_page'), #ZNY URL名称为category_detail_page
path( #ZNY 作者详情页路由
r'author/<author_name>.html', #ZNY 包含作者名称的URL
views.AuthorDetailView.as_view(), #ZNY 使用作者详情类视图
name='author_detail'), #ZNY URL名称为author_detail
path( #ZNY 作者分页路由
r'author/<author_name>/<int:page>.html', #ZNY 包含作者名称和页码的URL
views.AuthorDetailView.as_view(), #ZNY 使用相同的类视图处理分页
name='author_detail_page'), #ZNY URL名称为author_detail_page
path( #ZNY 标签详情页路由
r'tag/<slug:tag_name>.html', #ZNY 包含标签名称的URL
views.TagDetailView.as_view(), #ZNY 使用标签详情类视图
name='tag_detail'), #ZNY URL名称为tag_detail
path( #ZNY 标签分页路由
r'tag/<slug:tag_name>/<int:page>.html', #ZNY 包含标签名称和页码的URL
views.TagDetailView.as_view(), #ZNY 使用相同的类视图处理分页
name='tag_detail_page'), #ZNY URL名称为tag_detail_page
path( #ZNY 文章归档页路由
'archives.html',
cache_page(
60 * 60)(
views.ArchivesView.as_view()),
name='archives'),
path(
cache_page( #ZNY 使用缓存装饰器缓存页面
60 * 60)( #ZNY 缓存1小时
views.ArchivesView.as_view()), #ZNY 使用归档视图
name='archives'), #ZNY URL名称为archives
path( #ZNY 友情链接页路由
'links.html',
views.LinkListView.as_view(),
name='links'),
path(
views.LinkListView.as_view(), #ZNY 使用链接列表视图
name='links'), #ZNY URL名称为links
path( #ZNY 文件上传路由
r'upload',
views.fileupload,
name='upload'),
path(
views.fileupload, #ZNY 使用函数视图处理文件上传
name='upload'), #ZNY URL名称为upload
path( #ZNY 清理缓存路由
r'clean',
views.clean_cache_view,
name='clean'),
views.clean_cache_view, #ZNY 使用函数视图清理缓存
name='clean'), #ZNY URL名称为clean
]

Loading…
Cancel
Save