运行Django的sqlall命令时出现密码验证失败错误

时间:2014-01-17 17:08:10

标签: python django python-2.7

我正在和Django一起工作。现在我在第五章(模型),现在我正在处理一些问题。例如,当我尝试在shell中写入时: python.py manage.py sqlall my_app_name 我收到此消息:

Error message

我的错误在哪里?

P.S。我的my_app.models.py:

from django.db import models

class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_length=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.CharField(max_length=50)
    website = models.URLField()

class Author(models.Model):
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=40)
    email = models.EmailField()

class Book(models.Model):
    title = models.CharField(max_length=100)
    authors = models.ManyToManyField(Author)
    publisher = models.ForeignKey(Publisher)
    publication_date = models.DateField()

我的项目settings.py数据库配置:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydb',
        'USER': 'admin',                      # Not used with sqlite3.
        'PASSWORD': '123',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used wit
    }
}

最后 - 我的项目settings.py INSTALLED_APPS和MIDDLEWARE_CLASSES:

INSTALLED_APPS = (
    #'django.contrib.admin',
    #'django.contrib.auth',
    #'django.contrib.contenttypes',
    #'django.contrib.sessions',
    #'django.contrib.messages',
    #'django.contrib.staticfiles',
    'books', # MY APP NAME
)

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

如果您需要更多信息,请说明。提前谢谢!

1 个答案:

答案 0 :(得分:2)

错误消息非常明确,这是使用该用户名和密码连接到数据库时出现的问题。你是否在Postgres中设置了该帐户?