Extend compatibility with Django 6.0

This commit is contained in:
2025-12-03 23:24:53 +01:00
parent 935c439084
commit 66c3c3f51c
5 changed files with 29 additions and 25 deletions

View File

@@ -2,7 +2,7 @@ import html
from django.conf import settings
from django.contrib import admin
from django.utils.html import format_html, strip_tags
from django.utils.html import format_html, format_html_join, strip_tags
from adminsortable2.admin import SortableAdminBase, SortableInlineAdminMixin
@@ -44,7 +44,7 @@ class RollingClass(admin.ModelAdmin):
@admin.display(description="Country")
def country_flag(self, obj):
return format_html(
'<img src="{}" /> {}'.format(obj.country.flag, obj.country)
'<img src="{}" /> {}', obj.country.flag, obj.country.name
)
@@ -152,7 +152,7 @@ class RollingStockAdmin(SortableAdminBase, admin.ModelAdmin):
@admin.display(description="Country")
def country_flag(self, obj):
return format_html(
'<img src="{}" /> {}'.format(obj.country.flag, obj.country)
'<img src="{}" /> {}', obj.country.flag, obj.country.name
)
fieldsets = (
@@ -222,13 +222,14 @@ class RollingStockAdmin(SortableAdminBase, admin.ModelAdmin):
@admin.display(description="Invoices")
def invoices(self, obj):
if obj.invoice.exists():
html = "<br>".join(
"<a href=\"{}\" target=\"_blank\">{}</a>".format(
i.file.url, i
) for i in obj.invoice.all())
html = format_html_join(
"<br>",
"<a href=\"{}\" target=\"_blank\">{}</a>",
((i.file.url, i) for i in obj.invoice.all())
)
else:
html = "-"
return format_html(html)
return html
def download_csv(modeladmin, request, queryset):
header = [