From 9040dfe3b8e1f7437a9357141beb1b7cc26291a5 Mon Sep 17 00:00:00 2001 From: Versun Date: Mon, 24 Jun 2024 01:35:53 +0000 Subject: [PATCH] fix: handle missing category in OPML export --- utils/modelAdmin_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/modelAdmin_utils.py b/utils/modelAdmin_utils.py index 8473f7b..ed0116b 100644 --- a/utils/modelAdmin_utils.py +++ b/utils/modelAdmin_utils.py @@ -24,9 +24,10 @@ class CustomModelActions: def o_feed_export_as_opml(self, request, queryset): opml_obj = OPML() - + for item in queryset: - category_outline = Outline(text=item.category.name) + category = item.category.name if item.category else 'default' + category_outline = Outline(text=category) item_outline = Outline( title=item.name, text=item.name, @@ -49,12 +50,13 @@ def t_feed_export_as_opml(self, request, queryset): opml_obj = OPML() for item in queryset: + category = item.o_feed.category.name if item.o_feed.category else 'default' text = item.o_feed.name or "No Name" xml_url = request.build_absolute_uri( reverse("core:rss", kwargs={"feed_sid": item.sid}) ) - category_outline = Outline(text=item.o_feed.category.name) + category_outline = Outline(text=category) item_outline = Outline( title=text, text=text,