Python的'python manage.py syncdb'永远留下了空白

时间:2014-07-26 15:49:36

标签: python django postgresql

我是Django的新手(但不是Python)。我已经在Ubuntu Linux中成功安装了Postgresql 9.3,PgAdmin3和Psycopg2,并通过创建一个名为mysite的数据库和一些表来手动测试Postgresql,它运行正常。

我还测试了Python中的Django(2.7.6),它也显示了Django的正确版本(1.6)。

我正在使用Django's Official Documentation来设置所有内容。我能够执行

本地主机上的

django-admin.py startproject mysitepython manage.py runserver,端口8000没有任何错误。但是,每当我运行python manage.py syncdb时,它都会永远留下空白。如果有人可以帮助我解决这个问题,我会非常感激,被困了一个多星期了!

这是我的settings.py

    """
Django settings for mysite project.

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

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/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/1.6/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'mduc6%9mt+ca_ir_g6gq8nd(piu90cdtn^fn=u#2om8t=a8!en'

# 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',
)

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

ROOT_URLCONF = 'mysite.urls'

WSGI_APPLICATION = 'mysite.wsgi.application'


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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'HOST': '127.0.0.1',
        'NAME': 'mysite',
        'USER': 'akshat',
        'PASSWORD': 'password',
        'PORT': 8000
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/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/1.6/howto/static-files/

STATIC_URL = '/static/'

这是从~/Programming/Django/mysite查看的目录层次结构:

├── __init__.py
├── manage.py
└── mysite
    ├── __init__.py
    ├── __init__.pyc
    ├── settings.py
    ├── settings.py~
    ├── settings.pyc
    ├── urls.py
    ├── urls.pyc
    ├── wsgi.py
    └── wsgi.pyc

编辑:此外,它不显示运行开发服务器时的错误(在注释中提到),但它与python manage.py syncdb一起显示。

1 个答案:

答案 0 :(得分:0)

根据您当前的错误 -

django.db.utils.OperationalError: FATAL: password authentication failed for user "akshat" FATAL: password authentication failed for user "akshat"

- 您需要通过编辑文件 /etc/postgresql/9.1/main/pg_hba.conf 来设置Postgres的权限。

只需将以下行添加到文件末尾:

local database_name user_name md5

请务必使用您的数据库名称替换database_name以及使用实际用户名替换user_name