首页 > 解决方案 > 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 文件中的导入时,核心继续进行。有人可以帮我解决这个错误吗?

标签: pythondjangodjango-modelsdjango-admin

解决方案


推荐阅读