python - Django Admin: Numeric field filter -


how create filter numeric data in django admin range inputs?

p.s. found similar question, here suggest how group concrete ranges , last question activity 2 years ago.

django admin: how filter on integer field specific range of values

warning! parts of api django, mentioned in answer, considered internal , may changed in future releases of django without notification.

taking note mind, pretty easy create own filter. need is:

  1. subclass simplelistfilter , create method inside generate default range values , selected range values (for rendering template filter)
  2. set queryset method take parameters submitted filter , filter list queryset
  3. create template filter (based on admin/filter.html)
  4. set template property in simplelistfilter subclass, pointing filter template.

django pass template 3 parameters:

  • title - filter title (taken title property in class)
  • choices - list of dicts generated choices method of class (by default modifies list of tuples returned lookups method)
  • spec - class instance.

from point, can attribute or method of class, using spec in template, creation of filter should possible.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -