Reputation: 1
I have a static file that I use in my template.
I need to hide some information in this file code but I normally use settings.py constants to do that.
How can I instance a settings.py constant in a static file?
I tried {{CONSTANT}}
but iit doesn't work.
Upvotes: 0
Views: 218
Reputation: 1123400
Static files are not processed in any way, they are not templates, and you can't interpolate values into them. The static in the name means just that; variable interpolation would make them dynamic instead.
Create a new view that serves the same response, using a template.
Alternatively, consider putting the constant into your HTML you already generate with templates and have Javascript pull it out on the client side. That way your static resources can remain static, including JavaScript code.
Upvotes: 1