title: Execute Python Command from HTML template using Django
body: <p>I'm making a web interface for my Raspberry Pi using Django.</p>
  
  <p>I'm trying to execute python code which lights up a display by simply clicking a HTML button inside a Django Template. </p>
  
  <p>I currently light up the LED display by running this on command line:</p>
  
  <pre><code>cd rpi/
  sudo python bubbles.py
  </code></pre>
  
  <p>Which executes that ^ python code
  However I might want like to change the .py file depending on the HTML ID:</p>
  
  <pre><code>sudo python file_name.py
  </code></pre>
  
  <p>Anyways, this script needs to be executed via web browser so I wrote a view ...but I have no idea how to link a script to a view.
  My template:</p>
  
  <p>graphics_list.html</p>
  
  <pre><code>{% extends "base.html" %}
  {% block content %}
  &lt;h1&gt;{{ title }}&lt;/h1&gt;
  &lt;h1&gt; Scrolling Raspberry Pi LED Selection &lt;/h1&gt;
  {% for obj in object_list %}
  
  &lt;h3&gt;&lt;a href='{{ obj.get_absolute_url }}'&gt;{{ obj.name }}&lt;/a&gt;&lt;/h3&gt;
  
    &lt;img src="{{ obj.image.url }}" alt="..." class = "img-responsive"&gt;&lt;br&gt;
    &lt;p&gt;&lt;a href="{{ need_to_execute_script_somehow }}" class="btn btn-primary" id = "{{ obj.name }}" role= "button"&gt;Use&lt;/a&gt;&lt;/p&gt;
  
  {% endfor %}
  {% endblock content %}
  </code></pre>
  
  <p>I really don't know where to begin, should I use AJAX for this, PHP? </p>