Django Admin: How do I filter on an integer field for a specific range of values

FunLovinCoder picture FunLovinCoder · Oct 30, 2010 · Viewed 7.3k times · Source

How do I create a filter in Django Admin to only display records where an integer value lies between two values? For example, if I have a model Person, which has an age attribute, and I only want to display Person records where age is between 45 and 65.

Answer

sorin picture sorin · Jun 6, 2011

What you are looking is http://djangosnippets.org/snippets/587/ - the snippet is kinda old but works just fine after an additional minor change.

I uploaded the patched version at https://gist.github.com/1009903