python - Django 2.2.9:django.core.exceptions.ImproperlyConfigured:应用程序标签不是唯一的,重复:管理员
问题描述
我正在做一个大项目,我需要将我的应用程序分解为不同的可维护模块,并且每当我跨应用程序的不同模块进行导入时,我都会收到此错误。
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
现在我有一个名为asset_herarchi的模块和另一个模块名为db_configurations
在asset_herarchi我有以下两个模型:
from db_configurations.models import TableDataReferenceConfiguration
class Attribute(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=100, blank=False, null=False)
description = models.CharField(max_length=500, blank=True, null=True)
table_datareference_config = models.ForeignKey(TableDataReferenceConfiguration, related_name="data_reference_where_conditions", on_delete=models.CASCADE)
class Unit(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
name = models.CharField(max_length=150, blank=False, null=False)
description = models.CharField(max_length=500, blank=True, null=True)
formula = models.CharField(max_length=50, blank=True, null=True)
在db_configurations我有以下模型。
from asset_herarchi.models import Unit
class TableDataReferenceConfiguration(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True, editable=False)
table_name = models.CharField(max_length=100, null=False, blank=False, unique=False)
result_column_name = models.CharField(max_length=100, null=False, blank=False, unique=False)
unit_of_measure = models.ForeignKey(Unit, related_name="UOM_Table_Data_Reference_Configuration", on_delete=models.SET(None) )
behavior_rule = models.CharField(choices=Rule, null=False, blank=False, max_length=20)
behavior_order_by = models.CharField(max_length=100, null=True, blank=True, unique=False)
behavior_order_sorting = models.CharField(choices=Sorting, null=True, blank=True, max_length=20)
正如我之前提到的,我将应用程序拆分为不同的模块以便于维护对于一些业务逻辑需求,我需要将Unit模型导入db_configurations.model文件以创建与TableDataReferenceConfiguration的关系,并且我需要导入TableDataReferenceConfiguration模型回到asset_herarchi.models以创建与属性模型的关系,同时我希望模型TableDataReferenceConfiguration位于一个单独的模块中以满足某些业务需求。
由于多个模块之间的这些导入,我遇到了错误:django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: admin
当我评论任何 .models 文件中的导入时,核心继续进行。有人可以帮我解决这个错误吗?
解决方案
推荐阅读
- mongodb - 使用 ref 值更新多个元素
- javascript - 用 span 一次性替换剩余的一组单词
- python - Django 渲染字典
- swagger - 如何在 swagger.yaml / openapi.yaml 文件中访问 AWS SAM 映射
- gradle - 配置“编译”已过时。替换为实现后给出错误
- javascript - Javascript中WAV文件的左声道提取/淡出
- c++ - c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe:最终链接失败:设备上没有剩余空间
- reactjs - 尝试设置图像大小但在 setState 上出现错误
- flutter - 导航到新页面时 BLOC 丢失上下文
- python - 在Python中,如何根据一列中的值比较两个csv文件并从第一个文件中输出与第二个不匹配的记录