Skip to content

Commit 8d07c92

Browse files
committed
main: switch details_link to a simple tag
An inclusion_tag renders a template on every request, for the glibc page this meant calling Template.render() 7529 times(!) and loading ~ 5 seconds on my AMD Ryzen 7 5700X 8 Core. With this change we now do 3629 Template.render calls in 500 ms.
1 parent d01193a commit 8d07c92

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Diff for: main/templatetags/details_link.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from django import template
55
from django.conf import settings
6+
from django.utils.html import format_html
67

78
from main.templatetags import pgp
89
from main.utils import gitlab_project_name_to_path
@@ -18,9 +19,10 @@ def link_encode(url, query):
1819
return "%s?%s" % (url, data)
1920

2021

21-
@register.inclusion_tag('packages/details_link.html')
22+
@register.simple_tag
2223
def details_link(pkg):
23-
return {'pkg': pkg}
24+
link = '<a href="%s" title="View package details for %s">%s</a>'
25+
return format_html(link % (pkg.get_absolute_url(), pkg.pkgname, pkg.pkgname))
2426

2527

2628
@register.simple_tag

Diff for: templates/packages/details_link.html

-1
This file was deleted.

0 commit comments

Comments
 (0)