我已经在 .bash_profile 文件中设置了数据库密码的环境变量,但 PostgreSQL 的 PASSWORD 字段没有读取相同的内容。另外,我可以成功打印 production.py 文件中的密码,但 PostgreSQL 不会使用相同的密码。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': '********_db',
'USER': '*****_name',
'PASSWORD':os.environ.get("RS_DB_PWD"),
}
#The below will show the password correctly.
print(os.environ.get("RS_DB_PWD"))
Run Code Online (Sandbox Code Playgroud) 我最近开始学习 DjangoRestFramework,我遇到了两种创建模型实例的方法,一种是通过 Django Rest Framework CreateAPIView,另一种是 CreateModelMixin。所以我想知道它们之间以及执行相同功能的其他混合和视图之间有什么区别。