Skip to content

Commit 5e74e61

Browse files
committed
Fix asset circular import with templates
1 parent 22150bd commit 5e74e61

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

plain/plain/templates/jinja/globals.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from plain.assets.urls import get_asset_url
21
from plain.paginator import Paginator
32
from plain.utils import timezone
43

@@ -10,8 +9,16 @@ def url(viewname, *args, **kwargs):
109
return reverse(viewname, args=args, kwargs=kwargs)
1110

1211

12+
def asset(url_path):
13+
# An explicit callable we can control, but also delay the import of asset.urls->views->templates
14+
# for circular import reasons
15+
from plain.assets.urls import get_asset_url
16+
17+
return get_asset_url(url_path)
18+
19+
1320
default_globals = {
14-
"asset": get_asset_url,
21+
"asset": asset,
1522
"url": url,
1623
"Paginator": Paginator,
1724
"now": timezone.now,

0 commit comments

Comments
 (0)