I am making a Django website. I am not an expert but I understand the basics. However I am a complete rookie when it comes to javascript. I am using Django Templates to have each page on my website 'inherit' from a Base page (base.html). I want to include Javascript within a script tag of the base page that will only load when a certain page is loaded. I want to do something like this:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
...
...
</head>
<body>
...
<!-- Main Content -->
{% block content %}
{% endblock %}
...
<script> Some Script on every page </script>
<!-- Some Django if statement like the one below goes here -->
{% if this_page == '/special_page/' %}
<!-- a special script is loaded here -->
<script> Special Script </script>
{% endif %}
</body>
</html>
I am not sure if this can be done. Can this be done, and if so, is it a security risk?
I do not know what javascript code I would need to make this happen if any is needed. So I am looking for a code-based solution if there is one.