Skip to content

Commit 528e9a5

Browse files
committed
doc change and small optimization of register_frontend_media()
1 parent c631abb commit 528e9a5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fluent_contents/rendering/media.py

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ def register_frontend_media(request, media):
1010
Add a :class:`~django.forms.Media` class to the current request.
1111
This will be rendered by the ``render_plugin_media`` template tag.
1212
"""
13+
if media is ImmutableMedia.empty_instance:
14+
return
15+
1316
if not hasattr(request, "_fluent_contents_frontend_media"):
1417
request._fluent_contents_frontend_media = Media()
1518

@@ -19,6 +22,11 @@ def register_frontend_media(request, media):
1922
def get_frontend_media(request):
2023
"""
2124
Return the media that was registered in the request object.
25+
26+
.. note::
27+
The output of plugins is typically cached. Changes the the
28+
registered media only show up after flushing the cache,
29+
or re-saving the items (which flushes the cache).
2230
"""
2331
return (
2432
getattr(request, "_fluent_contents_frontend_media", None)

fluent_contents/templatetags/fluent_contents_tags.py

+5
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ def render_content_items_media(parser, token):
368368
{% render_content_items_media js %}
369369
{% render_content_items_media js local %}
370370
{% render_content_items_media js external %}
371+
372+
.. note::
373+
The output of plugins is typically cached. Changes the the
374+
registered media only show up after flushing the cache,
375+
or re-saving the items (which flushes the cache).
371376
"""
372377
return RenderContentItemsMedia.parse(parser, token)
373378

0 commit comments

Comments
 (0)