Django CONN_MAX_AGE设置错误

时间:2014-05-06 21:04:10

标签: python django

尝试在Django 1.6中设置unsupported operand type(s) for +: 'float' and 'str'时,我得到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',
    }
}

1 个答案:

答案 0 :(得分:12)

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',
    }
}