Django CONN_MAX_AGE 设置错误
我在使用Django 1.6设置 CONN_MAX_AGE
时,遇到了 unsupported operand type(s) for +: 'float' and 'str'
这个错误。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myDB',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': '',
'CONN_MAX_AGE': '60', # seconds for persistent connection, since Django 1.6
'PORT': '5432',
}
}
1 个回答
17
和PORT
不同,CONN_MAX_AGE
这个设置要用整数来表示(而不是用字符串)。
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'myDB',
'USER': 'myuser',
'PASSWORD': 'mypass',
'HOST': '',
'CONN_MAX_AGE': 60, # seconds for persistent connection, since Django 1.6
'PORT': '5432',
}
}