Django Simple Search


The django admin has a useful search_fields option, which adds search functionality to the change list via simple configuration:

class MyModelAdmin(admin.ModelAdmin):
    search_fields = ('title', 'description', '=id')

It's not very smart, but something like it can often come in handy on the frontend. Django simple search aims to provide the same functionality and level of convenience on the frontend as search_fields does in the admin.


pip install django-simple-search

Or download the source from

Django 1.8 or higher is required.

Quick start

from simple_search import search_filter
from .models import MyModel

query = 'test'
search_fields = ['^title', 'description', '=id']
f = search_filter(search_fields, query)
filtered = MyModel.objects.filter(f)

For convenience you can create a search form class via the provided factory:

from .models import MyModel
from simple_search import search_form_factory

SearchForm = search_form_factory(MyModel.objects.all(),
                                 ['^title', 'description'])

See the documentation for more information