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