From 188b2785328ef32f6472e301d9467a36a6f6c70a Mon Sep 17 00:00:00 2001 From: nanoy Date: Sun, 23 Jun 2019 11:02:37 +0200 Subject: [PATCH] Fix search in admin --- gestion/admin.py | 8 ++++---- users/admin.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gestion/admin.py b/gestion/admin.py index aa5508c..60d2035 100644 --- a/gestion/admin.py +++ b/gestion/admin.py @@ -17,7 +17,7 @@ class ConsumptionHistoryAdmin(SimpleHistoryAdmin): """ list_display = ('customer', 'product', 'quantity', 'paymentMethod', 'date', 'amount') ordering = ('-date', ) - search_fields = ('customer', 'product') + search_fields = ('customer__username', 'customer__first_name', 'customer__last_name', 'product__name') list_filter = ('paymentMethod',) class KegAdmin(SimpleHistoryAdmin): @@ -35,7 +35,7 @@ class KegHistoryAdmin(SimpleHistoryAdmin): """ list_display = ('keg', 'openingDate', 'closingDate', 'isCurrentKegHistory', 'quantitySold') ordering = ('-openingDate', 'quantitySold') - search_fields = ('keg',) + search_fields = ('keg__name',) list_filter = ('isCurrentKegHistory', 'keg') class MenuHistoryAdmin(SimpleHistoryAdmin): @@ -70,7 +70,7 @@ class ReloadAdmin(SimpleHistoryAdmin): """ list_display = ('customer', 'amount', 'date', 'PaymentMethod') ordering = ('-date', 'amount', 'customer') - search_fields = ('customer',) + search_fields = ('customer__username', 'customer__first_name', 'customer__last_name') list_filter = ('PaymentMethod', ) class RefundAdmin(SimpleHistoryAdmin): @@ -79,7 +79,7 @@ class RefundAdmin(SimpleHistoryAdmin): """ list_display = ('customer', 'amount', 'date') ordering = ('-date', 'amount', 'customer') - search_fields = ('customer',) + search_fields = ('customer__username', 'customer__first_name', 'customer__last_name') class CategoryAdmin(SimpleHistoryAdmin): """ diff --git a/users/admin.py b/users/admin.py index c222b6e..3ee28d9 100644 --- a/users/admin.py +++ b/users/admin.py @@ -11,7 +11,7 @@ class CotisationHistoryAdmin(SimpleHistoryAdmin): """ list_display = ('user', 'amount', 'duration', 'paymentDate', 'endDate', 'paymentMethod') ordering = ('user', 'amount', 'duration', 'paymentDate', 'endDate') - search_fields = ('user',) + search_fields = ('user__username', 'user__first_name', 'user__last_name') list_filter = ('paymentMethod', ) class BalanceFilter(admin.SimpleListFilter): @@ -43,7 +43,7 @@ class ProfileAdmin(SimpleHistoryAdmin): """ list_display = ('user', 'credit', 'debit', 'balance', 'school', 'cotisationEnd', 'is_adherent') ordering = ('user', '-credit', '-debit') - search_fields = ('user',) + search_fields = ('user__username', 'user__first_name', 'user__last_name') list_filter = ('school', BalanceFilter) class WhiteListHistoryAdmin(SimpleHistoryAdmin): @@ -52,7 +52,7 @@ class WhiteListHistoryAdmin(SimpleHistoryAdmin): """ list_display = ('user', 'paymentDate', 'endDate', 'duration') ordering = ('user', 'duration', 'paymentDate', 'endDate') - search_fields = ('user',) + search_fields = ('user__username', 'user__first_name', 'user__last_name') admin.site.register(Permission, SimpleHistoryAdmin) admin.site.register(School, SimpleHistoryAdmin)