perf: 性能与资源优化 - 提取内联资源、数据库查询优化、限流与缓存增强
主要优化: - templates/index.html: 220KB → 28KB,内联CSS/JS提取为静态文件 - menu/serializers.py: 修复 Order.ingredients_summary N+1 查询问题 - menu/services/dish_service.py: 移除多余查询,添加 only() 限制字段 - menu/views.py: 上传接口添加每分钟20次限流 - static/js/api.js: 统一API错误处理 - zhangmenu/settings.py: 添加Whitenoise压缩、Redis缓存支持、环境变量配置 - static/css/app.css, static/js/app.js: 提取的内联资源文件 - 新增 migrations, requirements.txt, .env.example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f1994c869d
commit
94647e2b4b
+24
-1
@@ -1,3 +1,26 @@
|
||||
from django.contrib import admin
|
||||
from .models import Dish, DishCategory, Order
|
||||
|
||||
# Register your models here.
|
||||
|
||||
@admin.register(DishCategory)
|
||||
class DishCategoryAdmin(admin.ModelAdmin):
|
||||
list_display = ['id', 'name', 'icon', 'order']
|
||||
list_editable = ['name', 'icon', 'order']
|
||||
search_fields = ['name']
|
||||
|
||||
|
||||
@admin.register(Dish)
|
||||
class DishAdmin(admin.ModelAdmin):
|
||||
list_display = ['id', 'name', 'category', 'view_count', 'created_at']
|
||||
list_filter = ['category', 'created_at']
|
||||
search_fields = ['name', 'description']
|
||||
raw_id_fields = ['category']
|
||||
|
||||
|
||||
@admin.register(Order)
|
||||
class OrderAdmin(admin.ModelAdmin):
|
||||
list_display = ['id', 'name', 'status', 'party_date', 'created_at', 'completed_at']
|
||||
list_filter = ['status', 'created_at']
|
||||
search_fields = ['name', 'note']
|
||||
readonly_fields = ['created_at', 'completed_at']
|
||||
filter_horizontal = ['dishes']
|
||||
|
||||
Reference in New Issue
Block a user