Django:应用标签不唯一
我一直在处理Django中重复标签的问题。根据这个回答,我在我的“jobs”项目文件夹里添加了以下文件:
jobs/apps.py
# jobs/apps.py
from django.apps import AppConfig
class JobsConfig(AppConfig):
name = 'jobs'
verbose_name = "jobs2"
jobs/init.py
# jobs/__init__.py
default_app_config = 'jobs.apps.JobsConfig'
不过,这些文件并没有太大帮助,我在尝试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
1 个回答
2
在你的 jobs
应用里,有一些旧版的迁移文件(像是 south: 0002_auto_del...)和新版的迁移文件(像是 django: 0001_initial)。最简单的解决办法就是删除所有带数字的迁移文件,使用命令 rm jobs/migrations/0???_*.py*
,然后再通过运行 manage.py makemigrations
来重新创建迁移文件。