新增“数据编辑”

This commit is contained in:
2025-11-13 21:58:52 +08:00
parent 2c31e1571f
commit 83a9dd04ba
6 changed files with 79 additions and 42 deletions

View File

@@ -1,6 +1,24 @@
from django.apps import AppConfig
import os
import sys
class ElasticConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "elastic"
def ready(self):
# 避免在 migrate、collectstatic 等管理命令中执行
if os.environ.get('RUN_MAIN') != 'true':
# Django 开发服务器会启动两个进程,只在主进程执行
return
# 避免在 manage.py 命令(除 runserver 外)中执行
if 'runserver' not in sys.argv:
return
# 延迟导入,避免循环导入或过早加载
from .es_connect import create_index_with_mapping
try:
create_index_with_mapping()
except Exception as e:
print(f"❌ ES 初始化失败: {e}")