This commit is contained in:
jeremygan2021
2026-02-12 14:23:36 +08:00
parent f00cc9a28e
commit b4ac97c3c2
7 changed files with 201 additions and 82 deletions

View File

@@ -7,9 +7,14 @@ django.setup()
from shop.models import ESP32Config
def populate():
# 检查数据库是否已有数据,如果有则跳过,避免每次构建都重置
if ESP32Config.objects.exists():
print("ESP32Config data already exists, skipping population.")
return
# 清除旧数据,避免重复累积
# 注意:在生产环境中慎用 delete
ESP32Config.objects.all().delete()
# ESP32Config.objects.all().delete()
configs = [
{