BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Django 1.10 Brings Full Text Search for PostgreSQL

Django 1.10 Brings Full Text Search for PostgreSQL

This item in japanese

Bookmarks

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
Style

BT