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 的问题。
  • 修复无效日期输入导致 500 异常的问题。
  • 修复 params 就地修改产生副作用的问题。
  • 修复 JavaScript 使用非标准 window.location.query 的兼容性问题。
  • 新增单测覆盖正常/非法/空/列表参数/时区等场景。
  • 更新 .po 翻译文件头部信息。
  • 迁移打包配置至 pyproject.toml
  • 添加 build.sh 构建脚本。

v0.1.8

  • 添加项目仓库链接至 pyproject.toml
  • 更新文档说明。

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.8.tar.gz (10.1 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.8.tar.gz.

File metadata

File hashes

Hashes for django_admin_daterange_listfilter-0.1.8.tar.gz
Algorithm Hash digest
SHA256 05de0607ed42476be6a948f8123112d4f906b4036dec95d2028ac650efd0134c
MD5 47fbdb01f0fb4d675b3987347b0f63e9
BLAKE2b-256 719bd3945f5c1ca6e5ee433fcb1c11b0216016c245bc1bec000d85e8b0ad9234

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_admin_daterange_listfilter-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 7ab28d48d0fc321cc88b6e64b3ea6d62a7edf98a79fe6ab04ac5cab437684977
MD5 ebf2a65b432982e335e17106fb118347
BLAKE2b-256 9c6b32ab2b3c51538a47001ee3ea8300115a721641edd29d4c218a30b0c21164

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