It is well documented how to add an external ressource file to be included by a page containing a Django form (or widget, or admin): defining a nested Media
class with js
or css
members listing the approriate files.
This has the effect of adding include directive in the <head>
section, of the form:
<script type="text/javascript" src="http://static.example.com/animations.js"></script>
Now, what we would need is to be able to define an inline script, one whose content is laid out directly in the <head>
section, with the form:
<script type="text/javascript">
alert("Dynamic string content");
</script>
The rationale is that the content of this script should be generated programatically.
How would one go about defining inline Javascript content for a ModelAdmin
?