Skip to content

Commit

Permalink
Fix asset circular import with templates
Browse files Browse the repository at this point in the history
  • Loading branch information
davegaeddert committed Aug 15, 2024
1 parent 22150bd commit 5e74e61
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions plain/plain/templates/jinja/globals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from plain.assets.urls import get_asset_url
from plain.paginator import Paginator
from plain.utils import timezone

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


def asset(url_path):
# An explicit callable we can control, but also delay the import of asset.urls->views->templates
# for circular import reasons
from plain.assets.urls import get_asset_url

return get_asset_url(url_path)


default_globals = {
"asset": get_asset_url,
"asset": asset,
"url": url,
"Paginator": Paginator,
"now": timezone.now,
Expand Down

0 comments on commit 5e74e61

Please sign in to comment.