rafaponieman / django-suit-daterange-filter

Filter for django-admin allowing lookups by date range

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?) and python3.

django-suit-daterange-filter

Key features:

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

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.

About

Filter for django-admin allowing lookups by date range

License:MIT License


Languages

Language:Python 92.9%Language:CSS 4.3%Language:HTML 2.8%