简体   繁体   English

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

[英]Password Authentication Failure error when running Django's sqlall command

I am working allong with Django book. 我正在和Django一起工作。 Now I'm on the fifth chapter(Models) and right now I'm dealing with some problems. 现在我在第五章(模型),现在我正在处理一些问题。 For instance, when I'm trying to write in my shell: python.py manage.py sqlall my_app_name I am getting this message: 例如,当我尝试在我的shell中编写时: python.py manage.py sqlall my_app_name我收到此消息:

错误信息

Where is my mistake? 我的错误在哪里?

PS My my_app.models.py: PS我的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()

My project settings.py databases configuration: 我的项目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
    }
}

And finally - my project settings.py INSTALLED_APPS and MIDDLEWARE_CLASSES: 最后 - 我的项目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',
)

If you need any more information just say. 如果您需要更多信息,请说。 Thank you in advance! 先感谢您!

The error message is quite explicit that this is a problem with connecting to the database with that username and password. 错误消息非常明确,这是使用该用户名和密码连接到数据库时出现的问题。 Have you set that account up in Postgres? 你是否在Postgres中设置了该帐户?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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