summaryrefslogtreecommitdiff
path: root/docs/ref
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/ref
parent47789410dbf351fd17a7854492b7b5b99a66bb1c (diff)
Fixed #23423 -- Added unaccent lookup in django.contrib.postgres
Diffstat (limited to 'docs/ref')
-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
3 files changed, 45 insertions, 0 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.