Skip to content

Latest commit

 

History

History
63 lines (43 loc) · 1.67 KB

README.md

File metadata and controls

63 lines (43 loc) · 1.67 KB

Date range filter for django-admin

Build Status codecov PyPI version

Yet another filter for Django admin interface, adding possibility to lookup by date range. The filter is only compatible with django-suit (does anyone use ugly stock admin now?).

django-suit-daterange-filter

Key features:

  • Support both DateField and DateTimeField
  • User timezone support
  • Simplest ever (< 128 SLOC)
  • Well tested
  • Python 3.6 and 2.7 support

Installation

pip install django-suit-daterange-filter

Then add to the settings.INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'date_range_filter',
)

Usage

# admin.py


from date_range_filter import DateRangeFilter

class EggAdmin(admin.ModelAdmin):
  list_filters = (
    'is_spam',
    'egg_count',
    ('timestamp', DateRangeFilter),
  )

Issues

If you get JS errors about gettext, you should include django's built in i18n javascript, like this:

class EggAdmin(admin.ModelAdmin):
  ...
  class Media:
    js = ['/admin/jsi18n/']

This module is heavily inspired by django-daterange-filter.