Django:应用程序标签不是uniqu

2024-10-01 13:43:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在处理Django中重复标签的问题,从this answer开始,我将以下文件添加到我的“jobs”项目文件夹中:

工作/应用程序.py

# jobs/apps.py

from django.apps import AppConfig

class JobsConfig(AppConfig):
    name = 'jobs'
    verbose_name = "jobs2"

作业/初始化.py

^{pr2}$

这并没有太大帮助,我在尝试syncdb时仍然遇到错误:

"duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, duplicates: jobs

另外,从“name='jobs'”更改为“name='jobs2'”只会给我一个错误:

ImportError: No module named jobs2

文件结构

/opt/Webapp
    ├── userfiles
    ├── templates
    │   └── admin
    │       └── base.html
    ├── static
    │   ├── admin_tools
    │   │   ├── images
    │   │   │   └── apto.gif
    │   │   └── css
    │   │       └── theming.css
    │   └── admin
    │       └── css
    │           └── base.css
    ├── smartrecruitment
    │   ├── wsgi.py
    │   ├── urls.py
    │   ├── settings.pyc
    │   ├── settings.py
    │   ├── __init__.pyc
    │   └── __init__.py
    ├── requirements.txt
    ├── manage.py
    ├── jobs
    │   ├── views.py
    │   ├── urls.py
    │   ├── tests.py
    │   ├── testhelpers.py
    │   ├── templates
    │   │   └── jobs
    │   │       ├── test.html
    │   │       ├── success.html
    │   │       ├── registration.html
    │   │       ├── registrationcomplete.html
    │   │       └── application.html
    │   ├── tables.py
    │   ├── static
    │   │   └── jobs
    │   │       ├── styles
    │   │       │   ├── index.css
    │   │       │   ├── hide_admin_original.css
    │   │       │   └── application.css
    │   │       ├── style.css
    │   │       └── images
    │   │           └── apto.gif
    │   ├── models.py
    │   ├── migrations
    │   │   ├── __init__.py
    │   │   ├── 0002_auto__del_field_registrant_name__add_field_registrant_first_name__add_.py
    │   │   └── 0001_initial.py
    │   ├── lists.py
    │   ├── __init__.pyc
    │   ├── __init__.py
    │   ├── forms.py
    │   ├── apps.pyc
    │   ├── apps.py
    │   └── admin.py
    ├── fileuploads
    │   ├── tests.py
    │   ├── templates
    │   │   └── fileuploads
    │   │       ├── index.html
    │   │       ├── details.html
    │   │       ├── base.html
    │   │       └── add.html
    │   ├── models.pyc
    │   ├── models.py
    │   ├── __init__.pyc
    │   ├── __init__.py
    │   ├── forms.pyc
    │   ├── forms.py
    │   ├── context_processors.py
    │   └── admin.pyc
    ├── dashboard.pyc
    └── dashboard.py

Tags: appsnamepyaddbaseadmininitmodels
1条回答
网友
1楼 · 发布于 2024-10-01 13:43:13

在您的应用程序中,您可以混合使用旧样式(south:0002_auto_del…)和新样式(django:0001_initial)迁移。最简单的修复方法是删除所有编号的迁移rm jobs/migrations/0???_*.py*,并通过运行manage.py makemigrations重新创建迁移

相关问题 更多 >