BT

Django 1.10 Brings Full Text Search for PostgreSQL

| by James Chesters Follow 1 Followers on Aug 09, 2016. Estimated reading time: 2 minutes |

Version 1.10 of Django has been released, bringing full text search for PostgreSQL, official support for Unicode usernames and new-style middleware.

The major release for Django Software Foundation's dynamic language includes using database functions in the django.contrib.postgres.search module to ease the use of PostgreSQL’s full text search engine.

The team provides the following example of using a simple search against a single column in the database:

>>> Entry.objects.filter(body_text__search='Cheese')
[<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]

"Creating a to_tsvector in the database from the body_text field and a plainto_tsquery from the search term 'Cheese', both using the default database search configuration. The results are obtained by matching the query and the vector. To use the search lookup, 'django.contrib.postgres' must be in your INSTALLED_APPS."

Examples for SearchVector, SearchQuery, and SearchRank can also be found in the Django Documentation here.

Also new in Django 1.10 is the introduction of a new style of middleware that is intended as a solution for "the lack of strict request/response layering of the old-style of middleware described in DEP 0005."

A "framework of hooks into Django's request/response processing" Django's new middleware provides django.utils.deprecation.MiddlewareMixin for creating middleware classes compatible with MIDDLEWARE and MIDDLEWARE_CLASSES.

According to documentation, "the mixin provides an __init__() method that accepts an optional get_response argument and stores it in self.get_response," as detailed below:

The __call__() method:
  1. Calls self.process_request(request) (if defined).
  2. Calls self.get_response(request) to get the response from later middleware and the view.
  3. Calls self.process_response(request, response) (if defined).
  4. Returns the response.

News of the latest Django release was met with approval online, and repeated requests for Channels.

HackerNews user Tom Forbes commented on the discussion Django 1.10 released, "Shame about Channels, but I see the logic in not including it," with user ubernostrum replying, "Channels will get there. It just wasn't quite ready on time for 1.10. Hopefully it will be ready on time for 1.11, and then it'll ship in Django."

User passiveincomelg was less sure, saying "I'm somewhat conflicted about Channels. On the one hand it's cool what you can do with it and the design cleverly avoids rewriting all of Django to be async. On the other hand, it is crazy how many shenanigans one needs to pull off to achieve what comes for free with Go or Erlang."

Django 1.10 also includes some backward incompatible changes, while other features have been dropped at the end of their deprecation cycle.

Among the features removed are the ability to use a dotted Python path for the LOGIN_URL and LOGIN_REDIRECT_URL settings, modules including django.core.context_processors, django.db.models.sql.aggregates, and django.contrib.gis.db.models.sql.aggregates, support for calling a SQLCompiler directly as an alias for calling its quote_name_unless_alias method, and a number of private APIs.

A free and open source web application framework written in Python, Django is released via a 3-clause BSD license and welcomes contributions from the InfoQ community.

Anyone looking to help improve and contribute towards Django should visit docs.djangoproject.com/en/dev/internals/contributing/.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT