From eb2b861d48ca60546652fdf032af20207fd93b43 Mon Sep 17 00:00:00 2001 From: ticvac Date: Sun, 1 Dec 2024 15:47:49 +0100 Subject: [PATCH 1/4] try except na sort --- mamweb/admin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mamweb/admin.py b/mamweb/admin.py index a58df505..9b4391db 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -56,8 +56,11 @@ def get_app_list(self, request, app_label=None): # Sort the models alphabetically within each app. - for app in app_list: - app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) + try: + for app in app_list: + app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) + except OSError: + pass # locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení return app_list From ddd12b684dc5c62d3eff2136ea67ab4e5cb1485f Mon Sep 17 00:00:00 2001 From: ticvac Date: Mon, 2 Dec 2024 11:51:19 +0100 Subject: [PATCH 2/4] komentar --- mamweb/admin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mamweb/admin.py b/mamweb/admin.py index 9b4391db..8a5f16af 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -56,7 +56,7 @@ def get_app_list(self, request, app_label=None): # Sort the models alphabetically within each app. - try: + try: # na macu nefunguje locale.strxfrm :-/ proto je tu try except block for app in app_list: app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) except OSError: From 9c4c60765e00d6014a96eca889abfc9fb394dcc6 Mon Sep 17 00:00:00 2001 From: ticvac Date: Tue, 7 Jan 2025 17:44:22 +0100 Subject: [PATCH 3/4] logger done --- mamweb/admin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mamweb/admin.py b/mamweb/admin.py index 8a5f16af..5e7bb820 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -7,6 +7,7 @@ import locale from django.contrib import admin from django.contrib.admin import AdminSite from django.contrib.flatpages.models import FlatPage +import logging # Note: we are renaming the original Admin and Form as we import them! from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld @@ -60,7 +61,9 @@ def get_app_list(self, request, app_label=None): for app in app_list: app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) except OSError: - pass # locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení + # locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení + logger = logging.getLogger(__name__) + logger.error('locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení') return app_list From a97071cd0377edd2cc2a94edb477f878f46d408c Mon Sep 17 00:00:00 2001 From: ticvac Date: Tue, 7 Jan 2025 17:49:16 +0100 Subject: [PATCH 4/4] not dumb error log message --- mamweb/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mamweb/admin.py b/mamweb/admin.py index 5e7bb820..a0ccf69e 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -60,10 +60,10 @@ def get_app_list(self, request, app_label=None): try: # na macu nefunguje locale.strxfrm :-/ proto je tu try except block for app in app_list: app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) - except OSError: + except OSError as e: # locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení logger = logging.getLogger(__name__) - logger.error('locale.strxfrm nefunguje na macu... :-/ -> neprovede se řazení') + logger.error(e) return app_list