简体   繁体   中英

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

I am new to Django (but not to Python). I've installed Postgresql 9.3, PgAdmin3 and Psycopg2 successfully in Ubuntu Linux and tested Postgresql manually by creating a database called mysite and a few tables and it's working fine.

I've also tested Django from Python ( 2.7.6 ) and it displays the correct version of Django too ( 1.6 ).

I am using Django's Official Documentation for setting up everything. I was able to execute

django-admin.py startproject mysite and python manage.py runserver on localhost, port 8000 without any errors. However, whenever I run python manage.py syncdb , it draws a blank forever. It would be really appreciated if someone could help me out with this problem, been stuck for more than a week!

Here's my 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/'

And here's the directory hierarchy when viewed from ~/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

Edit: Also, it doesn't show the error (mentioned in the comments) when the development server is ran, but it does with python manage.py syncdb .

Based on your current error of-

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

-you need to set up permissions for Postgres to use by editing the file /etc/postgresql/9.1/main/pg_hba.conf .

Just add the following line to the end of the file:

local database_name user_name md5

Be sure to replace database_name with your database name as well as user_name with the actual user name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM