File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change 22
33import os
44import logging
5+ from django .contrib .staticfiles .storage import staticfiles_storage , HashedFilesMixin
56from django .contrib .staticfiles .finders import find as find_static
67from django .core .serializers .json import DjangoJSONEncoder
78from django .utils .safestring import mark_safe
@@ -36,6 +37,15 @@ def render_props(self):
3637
3738def render_component (path_to_source , props = None , to_static_markup = False , json_encoder = None ):
3839 if not os .path .isabs (path_to_source ):
40+ # If its using the manifest staticfiles storage, to the hashed name.
41+ # eg. js/hello.js -> js/hello.d0bf07ff5f07.js
42+ if isinstance (staticfiles_storage , HashedFilesMixin ):
43+ try :
44+ path_to_source = staticfiles_storage .stored_name (path_to_source )
45+ except ValueError :
46+ # Couldn't find it.
47+ pass
48+ # Now resolve it to the absolute path using the finders
3949 path_to_source = find_static (path_to_source ) or path_to_source
4050
4151 if json_encoder is None :
You can’t perform that action at this time.
0 commit comments