Make sure to have some packages installed:
sudo apt-get install libpq-dev
pip install psycopg2
Database settings for 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',
}
}
In older versions you can also use the alias django.db.backends.postgresql_psycopg2
.
When using Postresql you'll have access to some extra features:
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