[英]Django psycopg2.OperationalError: fe_sendauth error but not connecting to postgresql database
I am using the following sqlite connection in my myapp/settings.py file: 我在myapp / settings.py文件中使用以下sqlite连接:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':testdb:',
#I also tried 'NAME': 'testdb',
},
}
in my manage.py file I am using: 在我的manage.py文件中,我正在使用:
if __name__ == "__main__":
os.environ.setdefault("myapp.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
On running ./manage.py migrate on the command line I get the following error: 在命令行上运行./manage.py迁移时,出现以下错误:
django.db.utils.OperationalError: fe_sendauth: no password supplied
I tried removing psycopg2 and re-ran the migration and get the following error: 我尝试删除psycopg2并重新运行迁移,并得到以下错误:
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named 'psycopg2'
I can't work out why django is trying to connect to a psql database where the only DATABSES configuration in the application is for sqlite3. 我不知道为什么django试图连接到psql数据库,其中应用程序中唯一的DATABSES配置是针对sqlite3的。
Could this be due to a dependency? 这可能是由于依赖关系造成的吗?
Try this, 尝试这个,
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
This might be helpful for you. 这可能对您有帮助。
Django only uses DATABASES
setting to generate migrations using a specific database driver. Django仅使用
DATABASES
设置来使用特定的数据库驱动程序生成迁移。 I believe somewhere, there is an import which is overriding your DATABASES
setting. 我相信某个地方有一个导入将覆盖您的
DATABASES
设置。 These are possible places to look for debugging in order of priority. 这些是按优先级顺序查找调试的可能位置。
settings.py
file after you set DATABASES
variable which might override it. DATABASES
变量后,任何导入settings.py
文件的操作都可能会覆盖它。 INSTALLED_APPS
. INSTALLED_APPS
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.