diff --git a/src/idp-plugins/idp_plugins/__init__.py b/src/idp-plugins/idp_plugins/__init__.py index cf0cab1a1..75ba91053 100644 --- a/src/idp-plugins/idp_plugins/__init__.py +++ b/src/idp-plugins/idp_plugins/__init__.py @@ -16,10 +16,10 @@ def load_plugins(): """加载插件""" # 插件目录(即当前目录) - plugin_base_dir = Path(__file__).resolve().parent + # Note: 这里不能使用Path(__file__).resolve(),因为resolve后会指向软链接目标目录,而非当前目录的真实目录 + plugin_base_dir = Path(__file__).parent # 当前包 package = f"{plugin_base_dir.parent.name}.{plugin_base_dir.name}" - # 子目录列表(即各个插件目录名) sub_dirs = [name for name in os.listdir(plugin_base_dir) if os.path.isdir(plugin_base_dir / name)] # 遍历加载各个插件 diff --git a/src/idp-plugins/idp_plugins/local/db_models.py b/src/idp-plugins/idp_plugins/local/db_models.py index ff4162991..43ffbfdbb 100644 --- a/src/idp-plugins/idp_plugins/local/db_models.py +++ b/src/idp-plugins/idp_plugins/local/db_models.py @@ -12,6 +12,8 @@ from django.db import models +# Note: 由于idp_plugins模块会被不同项目引入,model为了被Django App 加载,需要添加app_label, +# 同时由于不同项目自定义app不一样,所以这里直接使用公共的django.contrib.auth class DataSourceUser(models.Model): data_source_id = models.BigIntegerField("数据源") code = models.CharField("用户标识", max_length=128) @@ -24,6 +26,7 @@ class DataSourceUser(models.Model): phone_country_code = models.CharField("手机国际区号", max_length=16, null=True, blank=True) class Meta: + app_label = "django.contrib.auth" db_table = "data_source_datasourceuser" ordering = ["id"] @@ -43,4 +46,5 @@ class LocalDataSourceIdentityInfo(models.Model): username = models.CharField("用户名", max_length=128) class Meta: + app_label = "django.contrib.auth" db_table = "data_source_localdatasourceidentityinfo"