title: How to import .py file from django's static dir from within a brython.html template?
body: <p>Like the title says, I'm running a django webapp using Brython (NOT Javascript), hosted on Heroku, and would like to import a .py file located in the static folder. I am able to import and display the contents of the .py file, but when I try to import it, the webpage remains blank (white screen) with no errors (status 200). My debugging is possibly not developed enough to catch the error, but usually I will get a traceback when I have errors as debugging is on. So, the status 200 and blank white screen are important, I believe. Although debugging is not the subject of my post, any short insights into why I'm getting this result would be of interest.</p>
  <p>Here's the code I'm trying in the html template with a couple failing examples, and one suboptimal solution that does run mostly as hoped:</p>
  <pre><code>&lt;body onload=&quot;brython()&quot;&gt;
    &lt;script type=&quot;text/python&quot;&gt;
      from browser import document, html
  
      # This line works and displays the contents of the .py file in browser,
      # used to rule out my staticfile options in settings
  
      document &lt;= html.H1( open(&quot;{% static 'my_py_script.py' %}&quot;).read(), Id=&quot;main&quot;) 
  
      # Here is one method I've tried that causes the browser to remain blank on load
      # even though status is 200. I hope it will demonstrate what I'm aiming for.
  
      import &quot;{% static 'my_py_script.py' %}&quot;
  
  
      # I've seen this line suggested on stackOverflow as a non-brython solution
      # It also causes the page to be blank, status 200. I'm including it here so
      # people know I've checked the threads, but also curious if it is just
      # incompatible with Brython, or if there is something I'm doing wrong here?
  
      from django.templatetags.static import static
  
  
      # This next line executes with the desired result, but I've read that exec() is
      # quite slow and I'd prefer to use Python's import command if possible.
      # If this is not accurate, please let me know!
  
      exec(open(&quot;{% static 'my_py_script.py' %}&quot;).read())
  
    &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  <p>Thanks in advance for any help!</p>