【发布时间】:2014-12-05 12:02:14
【问题描述】:
我一直在处理 Django 中重复标签的问题,并且从 this answer 我已将以下文件添加到我的“工作”项目文件夹中:
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
【问题讨论】:
-
尝试用
label替换verbose_name:label = "jobs2"。我遇到了同样的问题,它对我有用。 -
同样清理所有
.*pyc,没有这个通常是行不通的。 -
谢谢,我删除了所有 .pyc 文件,用标签重命名了 verbose_name 然后运行了一个同步数据库,但这仍然给出了错误..
-
在
name=jobs中,jobs是否是该模块的完整路径(来自源根目录)? -
请查看我在 /opt/Webapp 的文件夹结构
标签: python django django-models django-1.7