---
title: "django.contrib.postgres"
version: 1.10
locale: en
source: https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/
canonical: https://djangodocs.dev/en/1.10/ref/contrib/postgres/
---
# `django.contrib.postgres`

PostgreSQL has a number of features which are not shared by the other databases
Django supports. This optional module contains model fields and form fields for
a number of PostgreSQL specific data types.

Psycopg2 2.5 or higher is required, though we highly recommend using the latest
release. Some fields require higher versions.

> **Note**
>
> Django is, and will continue to be, a database-agnostic web framework. We
> would encourage those writing reusable applications for the Django
> community to write database-agnostic code where practical. However, we
> recognize that real world projects written using Django need not be
> database-agnostic. In fact, once a project reaches a given size changing
> the underlying data store is already a significant challenge and is likely
> to require changing the code base in some ways to handle differences
> between the data stores.
>
> Django provides support for a number of data types which will
> only work with PostgreSQL. There is no fundamental reason why (for example)
> a `contrib.mysql` module does not exist, except that PostgreSQL has the
> richest feature set of the supported databases so its users have the most
> to gain.

- [PostgreSQL specific aggregation functions](/en/1.10/ref/contrib/postgres/aggregates/)

  - [General-purpose aggregation functions](/en/1.10/ref/contrib/postgres/aggregates/#general-purpose-aggregation-functions)
  - [Aggregate functions for statistics](/en/1.10/ref/contrib/postgres/aggregates/#aggregate-functions-for-statistics)
  - [Usage examples](/en/1.10/ref/contrib/postgres/aggregates/#usage-examples)
- [PostgreSQL specific model fields](/en/1.10/ref/contrib/postgres/fields/)

  - [`ArrayField`](/en/1.10/ref/contrib/postgres/fields/#arrayfield)
  - [`HStoreField`](/en/1.10/ref/contrib/postgres/fields/#hstorefield)
  - [`JSONField`](/en/1.10/ref/contrib/postgres/fields/#jsonfield)
  - [Range Fields](/en/1.10/ref/contrib/postgres/fields/#range-fields)
- [PostgreSQL specific form fields and widgets](/en/1.10/ref/contrib/postgres/forms/)

  - [Fields](/en/1.10/ref/contrib/postgres/forms/#fields)
  - [Widgets](/en/1.10/ref/contrib/postgres/forms/#widgets)
- [PostgreSQL specific database functions](/en/1.10/ref/contrib/postgres/functions/)

  - [`TransactionNow`](/en/1.10/ref/contrib/postgres/functions/#transactionnow)
- [PostgreSQL specific lookups](/en/1.10/ref/contrib/postgres/lookups/)

  - [Trigram similarity](/en/1.10/ref/contrib/postgres/lookups/#trigram-similarity)
  - [`Unaccent`](/en/1.10/ref/contrib/postgres/lookups/#unaccent)
- [Database migration operations](/en/1.10/ref/contrib/postgres/operations/)

  - [Creating extension using migrations](/en/1.10/ref/contrib/postgres/operations/#creating-extension-using-migrations)
  - [`CreateExtension`](/en/1.10/ref/contrib/postgres/operations/#createextension)
  - [`HStoreExtension`](/en/1.10/ref/contrib/postgres/operations/#hstoreextension)
  - [`TrigramExtension`](/en/1.10/ref/contrib/postgres/operations/#trigramextension)
  - [`UnaccentExtension`](/en/1.10/ref/contrib/postgres/operations/#unaccentextension)
- [Full text search](/en/1.10/ref/contrib/postgres/search/)

  - [The `search` lookup](/en/1.10/ref/contrib/postgres/search/#the-search-lookup)
  - [`SearchVector`](/en/1.10/ref/contrib/postgres/search/#searchvector)
  - [`SearchQuery`](/en/1.10/ref/contrib/postgres/search/#searchquery)
  - [`SearchRank`](/en/1.10/ref/contrib/postgres/search/#searchrank)
  - [Changing the search configuration](/en/1.10/ref/contrib/postgres/search/#changing-the-search-configuration)
  - [Weighting queries](/en/1.10/ref/contrib/postgres/search/#weighting-queries)
  - [Performance](/en/1.10/ref/contrib/postgres/search/#performance)
  - [Trigram similarity](/en/1.10/ref/contrib/postgres/search/#trigram-similarity)
- [Validators](/en/1.10/ref/contrib/postgres/validators/)

  - [`KeysValidator`](/en/1.10/ref/contrib/postgres/validators/#keysvalidator)
  - [Range validators](/en/1.10/ref/contrib/postgres/validators/#range-validators)
