Skip to main content

为Django模型列表页的时间过滤器增加日期范围选择功能。

Project description

django-admin-daterange-listfilter

为Django模型列表页的时间过滤器增加日期范围选择功能。

使用方法

简化集成(django-app-requires)

本项目通过 app_requires 声明了依赖的 Django 应用,结合 django-app-requires 可自动补全 INSTALLED_APPS 中的依赖项,无需手动添加:

INSTALLED_APPS = [
    ...
    "django_admin_daterange_listfilter",
    ...
]

# 在 settings.py 末尾
from django_app_requires import patch_all as django_app_requires_patch_all
django_app_requires_patch_all()

patch_all() 会自动将 app_requires 中声明的依赖(如 django_static_jquery_ui 等)追加到 INSTALLED_APPS

传统手动配置

settings.py

INSTALLED_APPS = [
    ...
    "django_static_jquery_ui",
    "django_middleware_global_request",
    "django_listfilter_media_extension",
    "django_admin_daterange_listfilter",
    ...
]

MIDDLEWARE = [
    ...
    "django_middleware_global_request.middleware.GlobalRequestMiddleware",
    ...
]

admin.py

from django.contrib import admin
from django_admin_daterange_listfilter.filters import DateRangeFilter
from .models import Category


class CategoryAdmin(admin.ModelAdmin):
    list_display = [
        "title",
        "add_time",
        "mod_time",
    ]
    list_filter = [
        ("add_time", DateRangeFilter),
        ("mod_time", DateRangeFilter),
    ]


admin.site.register(Category, CategoryAdmin)

版本记录

v0.1.0

  • 版本首发。

v0.1.4

  • 添加中文i18n翻译。

v0.1.5

  • 添加default_app_config以增强兼容性。

v0.1.6

  • Doc update.

v0.1.7

  • 修复 QueryDict 参数值为 list 类型时触发 TypeError 的问题。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_admin_daterange_listfilter-0.1.7.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_admin_daterange_listfilter-0.1.7.tar.gz.

File metadata

File hashes

Hashes for django_admin_daterange_listfilter-0.1.7.tar.gz
Algorithm Hash digest
SHA256 04b3255803cdafb32d621246a2800ed3162583d93a110f2d0c5b8b5d1b3a7446
MD5 391dbefd425efad6ddc261120fa00568
BLAKE2b-256 d9e3d168ed3a3744382f10f5b5f0fd587abb01133c5eeb59faf7de94c605936e

See more details on using hashes here.

File details

Details for the file django_admin_daterange_listfilter-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_daterange_listfilter-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fd7bc7e4c45a1405b4d59b8cea1ec579a1eee3d34bb9a757616fdc19ee987e6c
MD5 7c2a7b776e789eb310bc847943d2a57e
BLAKE2b-256 4251ad81b03850d028bd7279692a6c3426acd73ca3dd0bf2991588ed6e4f27ae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page