我正在尝试运行python manage.py makemigration命令,但是我收到了以下错误消息:
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: accounts
我尝试将以下内容添加到我的accounts.apps.py
中from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'
label = 'my_accounts'
但是,这给了我以下错误消息:
django.core.exceptions.ImproperlyConfigured: Application names aren't unique, duplicates: accounts
我的security.settings.py安装的应用程序如下:
INSTALLED_APPS = [
'accounts',
'accounts.apps.AccountsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
是否出现此错误消息,因为我在installed_apps中有'accounts'和accounts.apps.accountsconfig?如何让AccountsConfig成为我安装的应用程序的一部分以允许我的迁移?下面是我的应用程序文件夹结构。
我正在使用以下内容添加迁移:
from __future__ import unicode_literals
from django.db import models
class AllEeActive(models.Model):
employee_last_name = models.CharField(db_column='Employee_Last_Name', max_length=50, blank=True, null=True) # Field name made lowercase.
employee_first_name = models.CharField(db_column='Employee_First_Name', max_length=50, blank=True, null=True) # Field name made lowercase.
employee_ntname = models.CharField(db_column='Employee_NTName',primary_key=True, serialize=False, max_length=50) # Field name made lowercase.
b_level = models.CharField(db_column='B_Level', max_length=10, blank=True, null=True) # Field name made lowercase.
group_name = models.CharField(db_column='Group_Name', max_length=100, blank=True, null=True) # Field name made lowercase.
r_level = models.CharField(db_column='R_Level', max_length=10, blank=True, null=True) # Field name made lowercase.
division_name = models.CharField(db_column='Division_Name', max_length=100, blank=True, null=True) # Field name made lowercase.
d_level = models.CharField(db_column='D_Level', max_length=10, blank=True, null=True) # Field name made lowercase.
market_name = models.CharField(db_column='Market_Name', max_length=100, blank=True, null=True) # Field name made lowercase.
coid = models.CharField(db_column='COID', max_length=50, blank=True, null=True) # Field name made lowercase.
unit_no = models.CharField(db_column='Unit_No', max_length=50, blank=True, null=True) # Field name made lowercase.
dept_no = models.CharField(db_column='Dept_No', max_length=50, blank=True, null=True) # Field name made lowercase.
department_desc = models.CharField(db_column='Department_Desc', max_length=50, blank=True, null=True) # Field name made lowercase.
employee_status = models.CharField(db_column='Employee_Status', max_length=50, blank=True, null=True) # Field name made lowercase.
job_desc = models.CharField(db_column='Job_Desc', max_length=50, blank=True, null=True) # Field name made lowercase.
position_desc = models.CharField(db_column='Position_Desc', max_length=50, blank=True, null=True) # Field name made lowercase.
supervisor_last_name = models.CharField(db_column='Supervisor_Last_Name', max_length=50, blank=True, null=True) # Field name made lowercase.
supervisor_first_name = models.CharField(db_column='Supervisor_First_Name', max_length=50, blank=True, null=True) # Field name made lowercase.
supervisor_job_desc = models.CharField(db_column='Supervisor_Job_Desc', max_length=50, blank=True, null=True) # Field name made lowercase.
cfo = models.CharField(db_column='CFO', max_length=255, blank=True, null=True) # Field name made lowercase.
email_address = models.CharField(db_column='Email_Address', max_length=250, blank=True, null=True) # Field name made lowercase.
location_code = models.CharField(db_column='Location_Code', max_length=20, blank=True, null=True) # Field name made lowercase.
location_code_desc = models.CharField(db_column='Location_Code_Desc', max_length=255, blank=True, null=True) # Field name made lowercase.
corporate_flag = models.CharField(db_column='Corporate_Flag', max_length=1, blank=True, null=True) # Field name made lowercase.
hire_date = models.DateTimeField(db_column='Hire_Date', blank=True, null=True) # Field name made lowercase.
termination_date = models.DateTimeField(db_column='Termination_Date', blank=True, null=True) # Field name made lowercase.
employee_status_id = models.IntegerField(db_column='Employee_Status_ID', blank=True, null=True) # Field name made lowercase.
qv_statusid = models.IntegerField(db_column='QV_StatusID', blank=True, null=True) # Field name made lowercase.
lawson_status_id = models.IntegerField(db_column='Lawson_Status_ID', blank=True, null=True) # Field name made lowercase.
load_date = models.DateTimeField(db_column='Load_Date', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = False
db_table = 'All_EE_Active'
然后我尝试使用我的python shell运行以下命令来验证迁移是否已完成:
>>> from accounts.models import AllEeActive
>>> All_EE_Active.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'All_EE_Active' is not defined
>>> AllEEActive.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'AllEEActive' is not defined
为什么python不能识别All_EE_Active或AllEeActive?它似乎接受了导入。