新增wiki命令文件

This commit is contained in:
2026-04-14 16:02:50 +08:00
parent 65803c911d
commit c6e3d3c5db
485 changed files with 12578 additions and 396 deletions

View File

@@ -0,0 +1,59 @@
---
title: "Django Admin定制"
type: concept
tags: [django, admin, customization]
sources: [tiktok-pm-python-django-project.md]
last_updated: 2026-04-14
---
## Definition
Django Admin是Django框架自带的管理后台可通过配置实现复杂的CRUD操作界面。
## Key Customization Points
### list_display
定义列表页显示的字段:
```python
list_display = ('source_id', 'title_short', 'store_name', 'final_price', 'sold')
```
### search_fields
配置快速关键词搜索:
```python
search_fields = ('source_id', 'title', 'store_name', 'category', 'seller_id')
```
### list_filter
配置多条件过滤侧边栏:
```python
list_filter = ('store_name', 'category', 'currency', 'final_price')
```
### fieldsets
字段分组显示:
```python
fieldsets = (
('Product Base Info', {
'fields': (('source_id', 'title'),)
}),
)
```
### inlines
内联关联模型(图片、视频、变体、评价):
```python
inlines = [ProductVariationInline, ProductImageInline, ProductVideoInline, ProductReviewInline]
```
### readonly_fields
不可编辑字段:
```python
readonly_fields = ('source_id', 'created_at', 'updated_at')
```
## Image Preview Modal
通过自定义CSS和JavaScript实现点击图片放大功能。
## Connections
- [[Django Admin定制]] ← part_of ← [[Django]]
- [[Django Admin定制]] ← manages ← [[Django ORM模型设计]]