Skip to content

Commit ea5f3ca

Browse files
committed
fix: update format_html usage for Django 6.0 compatibility
Django 6.0 requires format_html() to have arguments or kwargs. Changed static HTML strings to use mark_safe() instead, and properly formatted the CSS link with a placeholder. Changes: - enable_source(): Changed format_html() to mark_safe() - enable_quotes(): Changed format_html() to mark_safe() - font_awesome_css(): Fixed format_html() to use proper placeholder Fixes TypeError: args or kwargs must be provided.
1 parent 452a5b1 commit ea5f3ca

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pythonie/core/wagtail_hooks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from django.conf import settings
22
from django.utils.html import format_html, format_html_join
3+
from django.utils.safestring import mark_safe
34
from wagtail import hooks
45
from wagtail.whitelist import attribute_rule, check_url
56

67

78
@hooks.register("insert_editor_js")
89
def enable_source():
9-
return format_html(
10+
return mark_safe(
1011
"""
1112
<script>
1213
registerHalloPlugin('hallohtml');
@@ -52,7 +53,7 @@ def enable_quotes():
5253
((settings.STATIC_URL, filename) for filename in js_files),
5354
)
5455

55-
return js_includes + format_html(
56+
return js_includes + mark_safe(
5657
"""
5758
<script>
5859
registerHalloPlugin('clicktotweet');
@@ -64,7 +65,6 @@ def enable_quotes():
6465
@hooks.register("insert_editor_css")
6566
def font_awesome_css():
6667
return format_html(
67-
'<link rel="stylesheet" href="'
68-
+ settings.STATIC_URL
69-
+ 'css/font-awesome.min.css">'
68+
'<link rel="stylesheet" href="{}css/font-awesome.min.css">',
69+
settings.STATIC_URL
7070
)

0 commit comments

Comments
 (0)