在我的Django项目中,如果要使用postgresql,我想使用仅在postgresql中可用的queryset方法。
如何从settings.DATABASES检查数据库?
假设这种结构:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # could be: 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'
我的python技能太弱,无法遍历字典的结构=(
from django.conf import settings
if settings.DATABASES['default']['ENGINE'] == 'django.db.backends.postgresql_psycopg2':
# happy coding
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句