From 83f9537117a645c659633cc23d4391394e6dc7a7 Mon Sep 17 00:00:00 2001 From: VIBR0X <44766005+vedant-github@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:00:46 +0530 Subject: [PATCH] add filters in backend --- buyandsell/admin.py | 9 ++++++++- upload/management/commands/clean-images.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/buyandsell/admin.py b/buyandsell/admin.py index 6b801dc8..f89fda66 100644 --- a/buyandsell/admin.py +++ b/buyandsell/admin.py @@ -3,8 +3,15 @@ from buyandsell.models import Ban, Category, ImageURL, Product, Report # Register your models here. -admin.site.register(Product) admin.site.register(Category) admin.site.register(ImageURL) admin.site.register(Report) admin.site.register(Ban) + +class ProductAdmin(admin.ModelAdmin): + list_display = ('name', 'user', 'description', 'brand', 'time_of_creation', 'deleted', 'status') + list_filter = ('status', 'deleted') + search_fields = ('title', 'category', 'user') + ordering = ('-time_of_creation',) + +admin.site.register(Product, ProductAdmin) diff --git a/upload/management/commands/clean-images.py b/upload/management/commands/clean-images.py index 3a2117c3..9f46d8b6 100644 --- a/upload/management/commands/clean-images.py +++ b/upload/management/commands/clean-images.py @@ -31,7 +31,7 @@ def handle(self, *args, **options): Body.objects.filter(image_url__contains=url), ComplaintImage.objects.filter(image_url__contains=url), Community.objects.filter(Q(logo_image__contains=url) | Q(cover_image__contains=url)), - CommunityPost.objects.filter(image_url__contains=url) | + CommunityPost.objects.filter(image_url__contains=url), Product.objects.filter(product_image__contains=url) ]