Passing Django Template Variables to Javascript... securely
<script type="text/javascript">
var a = "{{Django_Variable}}"
</script>
I get this idea.
But what if these Django Template variables contain sensitive information?
I have written a Javascript application that needs to receive data from
Django, but my current implementation shamelessly displays all the details
in developer mode.
<script>
$(function() {
MyApp.init(
userid: 46,
hasPermission: False,
secretData: "Not anymore",
...
);
});
</script>
The data I'm trying to pass in are not as sensitive as credit card or
password information, but sensitive enough that I need to hide it. I have
considered firing AJAX GET after the page loads, but that just adds extra
overhead.
How do I pass in Django Template variables to my Javascript without
showing it in HTML?
Thank you.
No comments:
Post a Comment