FEATURE(pg): add DateTimeRangeFilter to panel admin

add DateTimeRangeFilter to panel admin
This commit is contained in:
Haydar Ghasemi 2026-04-27 14:44:39 +03:30
parent f5ce799a38
commit a52ba09460
4 changed files with 7 additions and 3 deletions

View file

@ -14,6 +14,7 @@ from django.urls import path
from .constans import StateChoices
from .forms import ApplicationGatewayPolicyForm
from .models import PaymentRequest, PNA, Fake, ApplicationGatewayPolicy, SEP
from rangefilter.filters import DateTimeRangeFilter
logger = logging.getLogger(__name__)
@ -74,7 +75,7 @@ class PaymentRequestAdmin(admin.ModelAdmin):
list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime',
'is_registered', 'created_at', 'application', 'gateway']
search_fields = ['application__uuid', 'application__client_id', 'amount', 'user__uuid']
list_filter = ['application', 'state', 'gateway']
list_filter = ['application', 'state', 'gateway', ('created_at', DateTimeRangeFilter), ('updated_at', DateTimeRangeFilter)]
actions = [export_exel, mark_as_registered]
def changelist_view(self, request, extra_context=None):

View file

@ -49,6 +49,7 @@ INSTALLED_APPS = [
'django_filters',
'jalali_date',
'django_admin_logs',
'rangefilter',
# local apps
'apps.core',
@ -63,7 +64,7 @@ MIDDLEWARE = [
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'utils.i18n.ForceAdminLanguageMiddleware',
# 'utils.i18n.ForceAdminLanguageMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',

View file

@ -20,3 +20,4 @@ django-redis
xlsxwriter
xlrd
django_admin_logs
django-admin-rangefilter

View file

@ -182,6 +182,7 @@ zope-event==5.0
# via gevent
zope-interface==7.2
# via gevent
django-admin-rangefilter==0.13.5
# The following packages are considered to be unsafe in a requirements file:
# setuptools