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 .constans import StateChoices
from .forms import ApplicationGatewayPolicyForm from .forms import ApplicationGatewayPolicyForm
from .models import PaymentRequest, PNA, Fake, ApplicationGatewayPolicy, SEP from .models import PaymentRequest, PNA, Fake, ApplicationGatewayPolicy, SEP
from rangefilter.filters import DateTimeRangeFilter
logger = logging.getLogger(__name__) 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', list_display = ['state', 'check_success_again', 'uuid', 'splited_amount', 'user_id', 'jajali_datetime',
'is_registered', 'created_at', 'application', 'gateway'] 'is_registered', 'created_at', 'application', 'gateway']
search_fields = ['application__uuid', 'application__client_id', 'amount', 'user__uuid'] 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] actions = [export_exel, mark_as_registered]
def changelist_view(self, request, extra_context=None): def changelist_view(self, request, extra_context=None):

View file

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

View file

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

View file

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