summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorThomas Chaumeny <t.chaumeny@gmail.com>2014-09-05 22:53:11 +0200
committerTim Graham <timograham@gmail.com>2014-11-28 18:22:20 -0500
commit17fe0bd808a47f37dd1351adb01a8ad2cc852f24 (patch)
treea25e46a939ec1471c54a2dadf8ed57ec029afe1e /docs
parent47789410dbf351fd17a7854492b7b5b99a66bb1c (diff)
Fixed #23423 -- Added unaccent lookup in django.contrib.postgres
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/contrib/postgres/index.txt1
-rw-r--r--docs/ref/contrib/postgres/lookups.txt36
-rw-r--r--docs/ref/contrib/postgres/operations.txt8
-rw-r--r--docs/releases/1.8.txt7
4 files changed, 49 insertions, 3 deletions
diff --git a/docs/ref/contrib/postgres/index.txt b/docs/ref/contrib/postgres/index.txt
index b23db125f2..4c04d48d32 100644
--- a/docs/ref/contrib/postgres/index.txt
+++ b/docs/ref/contrib/postgres/index.txt
@@ -26,5 +26,6 @@ a number of PostgreSQL specific data types.
fields
forms
+ lookups
operations
validators
diff --git a/docs/ref/contrib/postgres/lookups.txt b/docs/ref/contrib/postgres/lookups.txt
new file mode 100644
index 0000000000..83477a61fe
--- /dev/null
+++ b/docs/ref/contrib/postgres/lookups.txt
@@ -0,0 +1,36 @@
+===========================
+PostgreSQL specific lookups
+===========================
+
+Unaccent
+========
+
+.. fieldlookup:: unaccent
+
+The ``unaccent`` lookup allows you to perform accent-insensitive lookups using
+a dedicated PostgreSQL extension.
+
+This lookup is implemented using :class:`~django.db.models.Transform`, so it
+can be chained with other lookup functions. To use it, you need to add
+``'django.contrib.postgres'`` in your :setting:`INSTALLED_APPS` and activate
+the `unaccent extension on PostgreSQL`_. The
+:class:`~django.contrib.postgres.operations.UnaccentExtension` migration
+operation is available if you want to perform this activation using migrations).
+
+.. _unaccent extension on PostgreSQL: http://www.postgresql.org/docs/current/interactive/unaccent.html
+
+The ``unaccent`` lookup can be used on
+:class:`~django.db.models.CharField` and :class:`~django.db.models.TextField`::
+
+ >>> City.objects.filter(name__unaccent="México")
+ ['<City: Mexico>']
+
+ >>> User.objects.filter(first_name__unaccent__startswith="Jerem")
+ ['<User: Jeremy>', '<User: Jérémy>', '<User: Jérémie>', '<User: Jeremie>']
+
+.. warning::
+
+ ``unaccent`` lookups should perform fine in most use cases. However, queries
+ using this filter will generally perform full table scans, which can be slow
+ on large tables. In those cases, using dedicated full text indexing tools
+ might be appropriate.
diff --git a/docs/ref/contrib/postgres/operations.txt b/docs/ref/contrib/postgres/operations.txt
index 4b9b7f5c44..79c2021c39 100644
--- a/docs/ref/contrib/postgres/operations.txt
+++ b/docs/ref/contrib/postgres/operations.txt
@@ -25,3 +25,11 @@ HStoreExtension
A subclass of :class:`~django.contrib.postgres.operations.CreateExtension`
which will install the ``hstore`` extension and also immediately set up the
connection to interpret hstore data.
+
+UnaccentExtension
+-----------------
+
+.. class:: UnaccentExtension()
+
+ A subclass of :class:`~django.contrib.postgres.operations.CreateExtension`
+ which will install the ``unaccent`` extension.
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 8f4053168d..2a1ec35873 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -45,9 +45,10 @@ New PostgreSQL specific functionality
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Django now has a module with extensions for PostgreSQL specific features, such
-as :class:`~django.contrib.postgres.fields.ArrayField` and
-:class:`~django.contrib.postgres.fields.HStoreField`. A full breakdown of the
-features is available :doc:`in the documentation</ref/contrib/postgres/index>`.
+as :class:`~django.contrib.postgres.fields.ArrayField`,
+:class:`~django.contrib.postgres.fields.HStoreField`, and :lookup:`unaccent`
+lookup. A full breakdown of the features is available :doc:`in the
+documentation </ref/contrib/postgres/index>`.
New data types
~~~~~~~~~~~~~~