{"title":"django.contrib.postgres","version":"2.2","locale":"zh-hans","docname":"ref/contrib/postgres/index","url":"/zh-hans/2.2/ref/contrib/postgres/","canonical":"https://djangodocs.dev/zh-hans/2.2/ref/contrib/postgres/","summary":"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…","html":"<span id=\"django-contrib-postgres\"></span><h1><code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.postgres</span></code><a class=\"heading-anchor\" href=\"#module-django.contrib.postgres\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>PostgreSQL has a number of features which are not shared by the other databases\nDjango supports. This optional module contains model fields and form fields for\na number of PostgreSQL specific data types.</p>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Django is, and will continue to be, a database-agnostic web framework. We\nwould encourage those writing reusable applications for the Django\ncommunity to write database-agnostic code where practical. However, we\nrecognize that real world projects written using Django need not be\ndatabase-agnostic. In fact, once a project reaches a given size changing\nthe underlying data store is already a significant challenge and is likely\nto require changing the code base in some ways to handle differences\nbetween the data stores.</p>\n<p>Django provides support for a number of data types which will\nonly work with PostgreSQL. There is no fundamental reason why (for example)\na <code class=\"docutils literal notranslate\"><span class=\"pre\">contrib.mysql</span></code> module does not exist, except that PostgreSQL has the\nrichest feature set of the supported databases so its users have the most\nto gain.</p>\n</aside>\n<div class=\"toctree-wrapper compound\">\n<ul>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/aggregates/\">PostgreSQL specific aggregation functions</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/aggregates/#general-purpose-aggregation-functions\">General-purpose aggregation functions</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/aggregates/#aggregate-functions-for-statistics\">Aggregate functions for statistics</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/aggregates/#usage-examples\">Usage examples</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/\">PostgreSQL specific model fields</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#indexing-these-fields\">Indexing these fields</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#arrayfield\"><code class=\"docutils literal notranslate\"><span class=\"pre\">ArrayField</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#citext-fields\"><code class=\"docutils literal notranslate\"><span class=\"pre\">CIText</span></code> fields</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#hstorefield\"><code class=\"docutils literal notranslate\"><span class=\"pre\">HStoreField</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#jsonfield\"><code class=\"docutils literal notranslate\"><span class=\"pre\">JSONField</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/fields/#range-fields\">Range Fields</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/forms/\">PostgreSQL specific form fields and widgets</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/forms/#fields\">字段</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/forms/#widgets\">小部件</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/functions/\">PostgreSQL specific database functions</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/functions/#randomuuid\"><code class=\"docutils literal notranslate\"><span class=\"pre\">RandomUUID</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/functions/#transactionnow\"><code class=\"docutils literal notranslate\"><span class=\"pre\">TransactionNow</span></code></a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/\">PostgreSQL specific model indexes</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#brinindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">BrinIndex</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#btreeindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">BTreeIndex</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#ginindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">GinIndex</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#gistindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">GistIndex</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#hashindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">HashIndex</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/indexes/#spgistindex\"><code class=\"docutils literal notranslate\"><span class=\"pre\">SpGistIndex</span></code></a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/lookups/\">PostgreSQL specific lookups</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/lookups/#trigram-similarity\">Trigram similarity</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/lookups/#unaccent\"><code class=\"docutils literal notranslate\"><span class=\"pre\">Unaccent</span></code></a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/\">Database migration operations</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#creating-extension-using-migrations\">Creating extension using migrations</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#createextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">CreateExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#btreeginextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">BtreeGinExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#btreegistextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">BtreeGistExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#citextextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">CITextExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#cryptoextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">CryptoExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#hstoreextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">HStoreExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#trigramextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">TrigramExtension</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/operations/#unaccentextension\"><code class=\"docutils literal notranslate\"><span class=\"pre\">UnaccentExtension</span></code></a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/\">Full text search</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#the-search-lookup\">The <code class=\"docutils literal notranslate\"><span class=\"pre\">search</span></code> lookup</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#searchvector\"><code class=\"docutils literal notranslate\"><span class=\"pre\">SearchVector</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#searchquery\"><code class=\"docutils literal notranslate\"><span class=\"pre\">SearchQuery</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#searchrank\"><code class=\"docutils literal notranslate\"><span class=\"pre\">SearchRank</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#changing-the-search-configuration\">Changing the search configuration</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#weighting-queries\">Weighting queries</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#performance\">Performance</a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/search/#trigram-similarity\">Trigram similarity</a></li>\n</ul>\n</li>\n<li class=\"toctree-l1\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/validators/\">Validators</a><ul>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/validators/#keysvalidator\"><code class=\"docutils literal notranslate\"><span class=\"pre\">KeysValidator</span></code></a></li>\n<li class=\"toctree-l2\"><a class=\"reference internal\" href=\"/zh-hans/2.2/ref/contrib/postgres/validators/#range-validators\">Range validators</a></li>\n</ul>\n</li>\n</ul>\n</div>","rootId":"module-django.contrib.postgres","toc":[],"breadcrumbs":[{"docname":"ref/index","title":"API参考","url":"/zh-hans/2.2/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/zh-hans/2.2/ref/contrib/"}],"prev":{"docname":"ref/contrib/messages","title":"The messages framework","url":"/zh-hans/2.2/ref/contrib/messages/"},"next":{"docname":"ref/contrib/postgres/aggregates","title":"PostgreSQL specific aggregation functions","url":"/zh-hans/2.2/ref/contrib/postgres/aggregates/"},"formats":{"html":"/zh-hans/2.2/ref/contrib/postgres/","markdown":"/zh-hans/2.2/ref/contrib/postgres.md","json":"/zh-hans/2.2/ref/contrib/postgres.json"},"source":"https://github.com/django/django/blob/stable/2.2.x/docs/ref/contrib/postgres/index.txt","official":"https://docs.djangoproject.com/zh-hans/2.2/ref/contrib/postgres/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}