Skip to main content

Search List class-based views for Django

Project description


Build Status

This package provides a Django class-based view used for showing a list of objects with a search form. Full documentation at (


  • allows searching multiple fields
  • supports pagination
  • set filtering operators for each field
  • set fixed filters
  • use lists of values for filters


From pypi:

pip install django-search-views

From source:

python install


Important: until v.1.0 API might be subject to changes. Please take a look at the changelog and don’t hesitate to mail us or open an issue if you have troubles migration from an older version. Sorry about this!.




The following code sets up model, form and view for displaying an “Actors List”.

class Actor(models.Model):
    name = models.CharField(max_length=32)
    surname = models.CharField(max_length=32)
    age = models.IntegerField()

from .models import Actor
from django import forms
class ActorSearchForm(forms.Form):
    search_text =  forms.CharField(
                    required = False,
                    label='Search name or surname!',
                    widget=forms.TextInput(attrs={'placeholder': 'search here!'})

    search_age_exact = forms.IntegerField(
                    required = False,
                    label='Search age (exact match)!'

    search_age_min = forms.IntegerField(
                    required = False,
                    label='Min age'

    search_age_max = forms.IntegerField(
                    required = False,
                    label='Max age'

from .model import Actor
from .forms import ActorSearchForm
from import SearchListView
from search_views.filters import BaseFilter

class ActorsFilter(BaseFilter):
    search_fields = {
        'search_text' : ['name', 'surname'],
        'search_age_exact' : { 'operator' : '__exact', 'fields' : ['age'] },
        'search_age_min' : { 'operator' : '__gte', 'fields' : ['age'] },
        'search_age_max' : { 'operator' : '__lte', 'fields' : ['age'] },


class ActorsSearchList(SearchListView):
    model = Actor
    paginate_by = 30
    template_name = "actors/actors_list.html"
    form_class = ActorSearchForm
    filter_class = ActorsFilter

view template “actors/actors_list.html”:

{% extends "base.html" %}

{% block content%}

<div class="container">

    <h2>Actors list</h2>

    <form class="form-inline" action="" method="GET">
        {{ form }}
        <button class="btn" type="submit">Search</button>

    <table class="table table-bordered table-condensed">
        {% for object in object_list %}
        {% endfor %}

    {% if is_paginated %}
        {% include "paginator.html" %}
    {% endif %}


{% endblock %}



  • filters are now configured in their own class derived from searchlist_views.filters.BaseFilter.


  • Renamed main package from searchlist_views to search_views.


  • Python 3 compatibility

License and development

This project is MIT licensed and maintained by Inmagik, suggestions and pull requests are welcome via the Github project page

Project details

Release history Release notifications

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django-search-views-0.3.7.tar.gz (6.9 kB) Copy SHA256 hash SHA256 Source None Jan 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page