【问题标题】:Django manage.py syncdb errorDjango manage.py syncdb 错误
【发布时间】:2014-09-07 14:41:19
【问题描述】:

您好,我是 Django 新手,在输入“manage.py syncdb”时,我一直在命令提示符中收到此错误

Traceback (most recent call last):
  File "C:\Users\B3dog\Desktop\MyWebsite\mysite\manage.py", line 10, in <module>

    execute_from_command_line(sys.argv)
  File "C:\Python34\lib\site-packages\django-1.8-py3.4.egg\django\core\managemen
t\__init__.py", line 330, in execute_from_command_line`enter code here`
    utility.execute()
  File "C:\Python34\lib\site-packages\django-1.8-py3.4.egg\django\core\managemen
t\__init__.py", line 304, in execute
    django.setup()
  File "C:\Python34\lib\site-packages\django-1.8-py3.4.egg\django\__init__.py",
line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Python34\lib\site-packages\django-1.8-py3.4.egg\django\apps\registry.
py", line 89, in populate
    "duplicates: %s" % app_config.label)
django.core.exceptions.ImproperlyConfigured: Application labels aren't unique, d
uplicates: admin

我正在使用通过使用 django.get_version() 找到的 python 3.4.1 和 Django 版本 1.8。我知道 stackoverflow 上有关于此的答案,但我发现的答案都不是最新的。

编辑:我忘记包含我的 settings.py

"""
Django settings for mysite project.

For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pl=&jot_vf_(5ddtj6!pppl@ot^6@arj6(up76otxwqm3wj3)x'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'mysite.urls'

WSGI_APPLICATION = 'mysite.wsgi.application'


# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': 'mysite.db',
    }
}

# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'

【问题讨论】:

    标签: python django sqlite


    【解决方案1】:

    INSTALLED_APPS 中有两个 django.contrib.admin 条目。这是固定版本:

    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'django.contrib.admin',
    )
    

    【讨论】:

    • 你为什么是天才。像你这样能看到这些东西的人就是神。
    • @b3dog 谢谢,但它实际上只是遵循回溯提供的信息并了解一些关于 django 设置的细节。这并不难。你使用 Django 的次数越多,你看到的越多,你就会越喜欢这个框架:)
    • @Alvaro 是的,目前 1.8 是主干。
    • @Alvaro 1.8 有什么这么不稳定?作为初学者,我显然不知道。
    • @b3dog Django 团队“非常擅长维护他们的代码稳定”。然而,坚持当前版本总是更安全,因为它经历了几个阶段的测试(包括团队和用户)。我用的是1.6.5,等待1.7的发布
    猜你喜欢
    • 2011-04-15
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 2014-03-22
    • 2013-09-15
    • 2015-07-31
    • 2011-02-13
    • 2014-10-13
    相关资源
    最近更新 更多