Compare commits
2 Commits
d28ecf98ea
...
6129673ddc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6129673ddc | ||
|
|
8b6773bb98 |
@@ -115,7 +115,11 @@ class TranscriptionTaskViewSet(viewsets.ModelViewSet):
|
||||
}
|
||||
if project_id:
|
||||
try:
|
||||
task_data['project_id'] = int(project_id)
|
||||
p_id = int(project_id)
|
||||
# 只有当 ID > 0 时才认为是有效的项目 ID
|
||||
# 避免前端传递 0 或 Swagger 默认值导致的外键约束错误
|
||||
if p_id > 0:
|
||||
task_data['project_id'] = p_id
|
||||
except (ValueError, TypeError):
|
||||
pass # Ignore invalid project_id
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ django.setup()
|
||||
from shop.models import ESP32Config
|
||||
|
||||
def populate():
|
||||
# 检查数据库是否已有数据,如果有则跳过,避免每次构建都重置
|
||||
# 检查数据库是否已有数据,如果有则跳过,避免每次构建都重置!
|
||||
if ESP32Config.objects.exists():
|
||||
print("ESP32Config data already exists, skipping population.")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user