i have included a js file(eg:application.js) inside my html page but i couldn't able to use django template tag inside that js file ,is there any way to use django template tag directly inside external js file?
3 Answers
No, not if you include the application.js file as
<script src="application.js"></script>
The template loader form Django will just render this to the final output of the html code. The Django template tags/filters only render on template pages - they do not apply to external sources.
You could attempt to load the JavaScript file as text into the template. So instead of referencing an external file, you would basically "paste" the code from the file into the template.