From 33813c2bf5c7f043bf8818d2e7b36900b979815d Mon Sep 17 00:00:00 2001 From: Anton Date: Wed, 6 Dec 2023 16:00:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B8=D0=B0=D0=B2=D0=BB=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D1=8B=20=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA=20=D1=81=20=D0=BF=D0=BE=D0=B4=D0=B4?= =?UTF-8?q?=D0=B5=D1=80=D0=B6=D0=BA=D0=BE=D0=B9=20regex=20#10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adminpanel/settings.py | 7 +++++-- adminpanel/urls.py | 3 +-- adminpanelapp/admin.py | 21 +++++++++++++++++---- requirements.txt | 4 +++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/adminpanel/settings.py b/adminpanel/settings.py index b8723b7..f8b3ec2 100644 --- a/adminpanel/settings.py +++ b/adminpanel/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = ['*'] # Application definition INSTALLED_APPS = [ + 'django_admin_listfilter_dropdown', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -38,6 +39,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', 'adminpanelapp', + 'rangefilter', ] MIDDLEWARE = [ @@ -114,7 +116,7 @@ USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.1/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = '/static/' # Default primary key field type # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field @@ -122,4 +124,5 @@ STATIC_URL = 'static/' DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' ASGI_APPLICATION = 'adminpanelapp.asgi.application' -ASYNC_MODE = 'django' \ No newline at end of file +ASYNC_MODE = 'django' + diff --git a/adminpanel/urls.py b/adminpanel/urls.py index 6f7db62..2e33322 100644 --- a/adminpanel/urls.py +++ b/adminpanel/urls.py @@ -1,8 +1,7 @@ from django.contrib import admin from django.urls import path, include from django.views.generic import RedirectView -from django.conf import settings -from django.conf.urls.static import static + urlpatterns = [ path('admin/', admin.site.urls), diff --git a/adminpanelapp/admin.py b/adminpanelapp/admin.py index b7de0f2..1fb808c 100644 --- a/adminpanelapp/admin.py +++ b/adminpanelapp/admin.py @@ -1,21 +1,34 @@ +from datetime import timedelta, datetime from django.contrib.auth.models import User, Group from django.http import HttpResponseRedirect from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME from django.utils.safestring import mark_safe +from django_admin_listfilter_dropdown.filters import DropdownFilter from .models import Orders, Users - from django.contrib import admin, messages from django.urls import reverse - +from rangefilter.filters import DateRangeFilter class OrdersAdmin(admin.ModelAdmin): list_display = ( 'orderName', 'orderCreateDateTime', 'orderDesc', 'orderAddress', 'catID', 'userName', 'orderStatus', 'show_photo', 'show_photopay', - ) + ) actions = ['send_message'] exclude = ['orderAccess', 'userID', 'orderPhoto', 'orderPhotoPay'] + search_fields = ['orderName__regex', 'orderCreateDateTime__regex', 'orderDesc__regex', + 'orderAddress__regex', 'catID__regex', 'orderStatus__regex' + ] + + list_filter = [ + ('orderName', DropdownFilter), + ('orderAddress', DropdownFilter), + ('orderDesc', DropdownFilter), + ('catID', DropdownFilter), + ('orderCreateDateTime', DateRangeFilter) + + ] def userName(self, obj): @@ -82,4 +95,4 @@ admin.site.unregister(Group) # Снятие регистрации станда admin.site.register(User, CustomUserAdmin) # Регистрация настроенного класса администратора пользователей admin.site.register(Group, CustomGroupAdmin) # Регистрация настроенного класса администратора групп -admin.site.register(Orders, OrdersAdmin) +admin.site.register(Orders, OrdersAdmin) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c3219b5..f436904 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,6 @@ weasyprint Django==2.2.1 python-dotenv==0.21.1 requests==2.31.0 -urllib3==1.25.11 \ No newline at end of file +urllib3==1.25.11 +django-admin-list-filter-dropdown==1.0.3 +django-admin-rangefilter==0.11.2 \ No newline at end of file