Clone wiki

django-tsearch2 / Home


Django application that provide full-text search in PostgreSQL.



First, import tsearch2 in your file and run register method with model class as first parameter and dictionary of fields names with their weight as second parameter.

import tsearch2

tsearch2.register(YourModel, {'content': 'A', 'title': 'B', 'user__username': 'D'} )

It will attach search manager to your model with default name "index" and also add tsvector column to your database. As you can see, dictionary can use two underscores syntax to access related models. You can read about weights here.

After you have done with your model, insert to django shell, import your model and run


Now you can use full text search:"mystring")