---
slug: "django-admin-simplelistfilter"
title: "Creating Custom Filters in Django Admin"
description: "Using SimpleListFilter for Easy Implementation"
url: "https://www.ytyng.com/en/blog/django-admin-simplelistfilter"
publish_date: "2017-02-26T10:25:28Z"
created: "2017-02-26T10:25:28Z"
updated: "2026-02-27T06:30:31.329Z"
categories: ["Django"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/411bd54d420e4cd4b6942d9ff4c788f2.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Creating Custom Filters in Django Admin

<p>Using SimpleListFilter for Easy Implementation</p>
<pre style="background-color: #ffffff; color: #000000; font-family: 'Menlo'; font-size: 9.0pt;"><span style="color: #000080; font-weight: bold;">from </span>django.contrib <span style="color: #000080; font-weight: bold;">import </span>admin</pre>
<pre style="background-color: #ffffff; color: #000000; font-family: 'Menlo'; font-size: 9.0pt;"><span style="color: #000080; font-weight: bold;">class </span>TicketStatusListFilter(admin.SimpleListFilter):<br />    title = <span style="color: #008080; font-weight: bold;">'Status'<br /></span><span style="color: #008080; font-weight: bold;">    </span>parameter_name = <span style="color: #008080; font-weight: bold;">'status_set'<br /></span><span style="color: #008080; font-weight: bold;"><br /></span><span style="color: #008080; font-weight: bold;">    </span><span style="color: #000080; font-weight: bold;">def </span>lookups(<span style="color: #94558d;">self</span>, request, model_admin):<br />        <span style="color: #000080; font-weight: bold;">return </span>(<br />            (<span style="color: #008080; font-weight: bold;">'incomplete'</span>, <span style="color: #008080; font-weight: bold;">'Incomplete'</span>),<br />            (<span style="color: #008080; font-weight: bold;">'completed'</span>, <span style="color: #008080; font-weight: bold;">'Completed'</span>),<br />        )<br /><br />    <span style="color: #000080; font-weight: bold;">def </span>queryset(<span style="color: #94558d;">self</span>, request, queryset):<br />        <span style="color: #000080; font-weight: bold;">if </span><span style="color: #94558d;">self</span>.value() == <span style="color: #008080; font-weight: bold;">'incomplete'</span>:<br />            <span style="color: #000080; font-weight: bold;">return </span>queryset.exclude(<span style="color: #660099;">status</span>=<span style="color: #008080; font-weight: bold;">'completed'</span>)<br />        <span style="color: #000080; font-weight: bold;">if </span><span style="color: #94558d;">self</span>.value() == <span style="color: #008080; font-weight: bold;">'completed'</span>:<br />            <span style="color: #000080; font-weight: bold;">return </span>queryset.filter(<span style="color: #660099;">status</span>=<span style="color: #008080; font-weight: bold;">'completed'</span>)</pre>
<pre style="background-color: #ffffff; color: #000000; font-family: 'Menlo'; font-size: 9.0pt;"><span style="color: #000080; font-weight: bold;">class </span>TicketAdmin(admin.ModelAdmin):<br />    list_filter = (TicketStatusListFilter,)</pre>
<p></p>
<p></p>
<p></p>
