数据库配置的另一种方式

root
abc abc
  • 6 Aug

settings.py

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'OPTIONS': {
'read_default_file': '/path/to/my.cnf',
},
}
}

my.cnf

[client]
database = NAME
user = USER
password = PASSWORD
default-character-set = utf8