簡體   English   中英

Python的'python manage.py syncdb'永遠畫出一片空白

[英]Python's 'python manage.py syncdb' draws a blank forever

我是Django的新手(但不是Python)。 我已經在Ubuntu Linux中成功安裝了Postgresql 9.3,PgAdmin3和Psycopg2,並通過創建名為mysite和一些表的數據庫手動測試了Postgresql,並且工作正常。

我還從Python( 2.7.6 )測試了Django,它也顯示了Django( 1.6 )的正確版本。

我正在使用Django的官方文檔來設置所有內容。 我能夠執行

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

根據您當前的錯誤-

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM