完善了首页和关于前端页面,以及解决了图片存储方案问题

This commit is contained in:
2026-10-20 04:53:06 +08:00
parent 16a75807ee
commit 7e45fa620e
20 changed files with 625 additions and 96 deletions
+13 -17
View File
@@ -1,23 +1,19 @@
"""
博客 app 的路由配置
把 URL 路径映射到视图函数
"""
from django.urls import path
# blog/urls.py
from django.urls import path, register_converter
from . import views
from .converters import UnicodeSlugConverter
register_converter(UnicodeSlugConverter, 'unislug')
# app_name 用于反向解析 URL
# 模板里用 {% url 'blog:post_list' %} 就会找到这里
app_name = 'blog'
urlpatterns = [
# 文章列表页
# URL: /
# name='post_list' 是反向解析的名字
path('', views.post_list, name='post_list'),
# 文章详情页
# URL: /<slug>/
# <slug:slug> 表示这部分是 slug 类型,传给 views.post_detail 的 slug 参数
path('<slug:slug>/', views.post_detail, name='post_detail'),
path('', views.category_list, name='category_list'),
# ✅ 用 unislug 替代 slug
path('category/<unislug:slug>/', views.category_detail, name='category_detail'),
path('post/<slug:slug>/', views.post_detail, name='post_detail'),
path('tag/<unislug:slug>/', views.tag_detail, name='tag_detail'),
path('about/', views.about_page, name='about'),
]