0
我正在用Django書籍工作allong。現在我在第五章(模型),現在我正在處理一些問題。例如,當我試圖在我的殼寫:python.py manage.py sqlall my_app_name我得到這個消息:運行Django的sqlall命令時密碼驗證失敗錯誤
哪裏是我的錯?
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',
)
如果您只需要說更多的信息。先謝謝你!
沒有關於連接用戶名和傳遞給數據庫的信息。此外,我無法在google上快速找到anythinf spesific。那麼也許你可以用很短的方式寫下這些內容?謝謝btw。 –
好吧,你在數據庫設置中選擇了「admin」/「123」。你從哪裏得到那個的?無論如何,這是一個關於Postgres的問題,而不是Django:您應該查看Postgres文檔以瞭解如何設置用戶名。如果你不想這樣做,只需使用sqlite3。 –
我切換到SQLite,現在它工作!謝謝 :-) –