为了通过在全新安装的 django trunk (1.4c1) 上运行的单元测试,有必要other
在 settings.py 中添加一个“虚拟”数据库,如下所示:-
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'mydb', # Or path to database file if using sqlite3.
'USER': 'myuser', # Not used with sqlite3.
'PASSWORD': 'mypassword', # Not used with sqlite3.
'HOST': 'localhost', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '5432', # Set to empty string for default. Not used with sqlite3.
},
# dummy sqlite3 database created to pass django's builtin unit tests
'other': {
'ENGINE': 'django.db.backends.sqlite3'
}
}
为什么会这样?在 django/db/utils.py 的ConnectionHandler
类中这个“ensure_defaults”函数的目的是什么?
只是想更深入地了解 django ......