title: Django: Get database object value in template using Ajax
body: <p>I want to fetch database object depending on user selection. I know one possible solution could be Ajax, but I don't know how to get about it. Here is the code:</p>
  
  <p><strong>view.py:</strong></p>
  
  <pre><code>def automation(request):
      //some code
      car = CAR.objects.get(ida_name='honda')
      model = car.model_set.all()
      //some code
  </code></pre>
  
  <p><strong>template.html:</strong></p>
  
  <pre><code>Select CAR: &lt;select id="car" name="car"&gt;
  {% for car in car_list %}
  &lt;option value="{{ car.id }}" id="{{ car.id }}"&gt;{{ car.car_name }}&lt;/option&gt;
  {% endfor %}
  &lt;/select&gt;
  
  Select car model: &lt;select id="model" name="model"&gt;
  {% for model in car.model_set.all %}
  &lt;option value="{{ forloop.counter }}"&gt;{{ model.model_name }}&lt;/option&gt;
  {% endfor %}
  &lt;/select&gt;
  </code></pre>
  
  <p>Here, I want to pass a name eg.'honda' from my template (as soon as user selects it in drop down) to my view.py which would then fetch the corresponding object and return the result back to my template in 'model' drop down list. (So, basically the car model list refreshes when user selects any car from the car drop down list)</p>
  
  <p><strong>Note:</strong> Model is in many-to-many relationship with Car in models.py</p>
  
  <p>I am stuck up here for quite long and any help would be really appreciated.</p>