title: Querying from AJAX in Django (GET)
body: <p>I have a template (<code>menu.html</code>), and I am making an AJAX call with JavaScript. Then, I want to process that call (throughout the GET parameters) and make a query from Django's ORM. \</p>
  <p>My JavaScript code is:</p>
  <pre><code>$.ajax(&quot;/showcart&quot;, {
          type: &quot;GET&quot;,
          data: {
              product: product,
              type: product_type
          },
          success: function(response) {
              console.log(&quot;SUCCES SUCCESS SUCCESS&quot;)
              console.log(response);
          },
          error: function(resp) {
              console.log(&quot;ERROR ERROR ERROR!&quot;)
              console.log(resp)
          }
  
      })
  </code></pre>
  <p><code>product</code> is the name of my product, and <code>product_type</code> is the size of my product. <br />
  Then, in my <code>views.py</code>, I handle this call with:</p>
  <pre><code>def showcart(request):
      product = request.GET['product']
      if request.GET['type'] == &quot;small&quot;:
          size = f&quot;{request.GET['type']}_price&quot;
      elif request.GET['type'] == &quot;large&quot;:
          size = f&quot;{request.GET['type']}_price&quot;
      else:
          size = &quot;price&quot;
  
      product_name = product.split(&quot;-&quot;)[0]
      product_id = product.split(&quot;-&quot;)[1]
  
      return JsonResponse(
          {
          &quot;product_name&quot;: product_name,
          &quot;product_id&quot;: product_id,
          &quot;size&quot;: size,
          &quot;queryresult&quot;: &quot;nothing here&quot;,
          }
      )
  </code></pre>
  <p>For example, <code>product_name</code> is &quot;Sub&quot; and I have a model in <code>models.py</code> called Sub. My goal is querying the price, for instance, with the <code>product_name</code>. But, since it is a <code>string</code> type, Django doesn't allow me to do that. Does anyone know how this works?</p>
  <p>Thanks,</p>