主要优化: - 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>
16 lines
562 B
Python
16 lines
562 B
Python
from django.urls import path, include
|
|
from rest_framework.routers import DefaultRouter
|
|
from . import views
|
|
|
|
router = DefaultRouter()
|
|
router.register(r'categories', views.DishCategoryViewSet, basename='dishcategory')
|
|
router.register(r'dishes', views.DishViewSet, basename='dish')
|
|
router.register(r'orders', views.OrderViewSet, basename='order')
|
|
|
|
urlpatterns = [
|
|
path('', views.index, name='index'),
|
|
path('api/', include(router.urls)),
|
|
path('api/parse-url/', views.ParseUrlView.as_view()),
|
|
path('api/upload/', views.upload_image, name='upload'),
|
|
]
|