PostgreSQL

确保安装了一些软件包:

sudo apt-get install libpq-dev
pip install psycopg2

PostgreSQL 的数据库设置:

#myapp/settings/settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'myprojectDB',
        'USER': 'myprojectuser',
        'PASSWORD': 'password',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

在旧版本中,你还可以使用别名 django.db.backends.postgresql_psycopg2

使用 Postresql 时,你可以访问一些额外的功能:

Modelfields:

ArrayField         # A field for storing lists of data. 
HStoreField        # A field for storing mappings of strings to strings. 
JSONField          # A field for storing JSON encoded data. 
IntegerRangeField  # Stores a range of integers 
BigIntegerRangeField # Stores a big range of integers 
FloatRangeField    # Stores a range of floating point values. 
DateTimeRangeField # Stores a range of timestamps