fixes for idea render and other

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-17 05:58:13 +00:00
parent 4bba5a9a1f
commit 9f826c92f8
4 changed files with 63 additions and 8 deletions

View File

@@ -354,13 +354,19 @@ class SectorInline(TabularInline):
def get_keywords_count(self, obj):
if obj.pk:
return getattr(obj, 'keywords_set', obj.keywords_set).count()
try:
return obj.keywords_set.count()
except (AttributeError, Exception):
return 0
return 0
get_keywords_count.short_description = 'Keywords'
def get_clusters_count(self, obj):
if obj.pk:
return getattr(obj, 'clusters_set', obj.clusters_set).count()
try:
return obj.clusters_set.count()
except (AttributeError, Exception):
return 0
return 0
get_clusters_count.short_description = 'Clusters'
@@ -404,8 +410,8 @@ class SiteAdmin(ExportMixin, AccountAdminMixin, Igny8ModelAdmin):
def get_api_key_display(self, obj):
"""Display API key with copy button"""
from django.utils.html import format_html
if obj.wp_api_key:
from django.utils.html import format_html
return format_html(
'<div style="display:flex; align-items:center; gap:10px;">'
'<code style="background:#f0f0f0; padding:5px 10px; border-radius:3px;">{}</code>'