title: Django dynamic Form using json data
body: <p>I have seen many examples of dynamic forms, but it seems I could not find my answer, So please help me on the requirement below:</p>
  
  <p>I have a json file including some data as below:</p>
  
  <pre><code>    {
      "cat1": {
          "product1": {
              "item1": "check box p1i1",
              "item2": "check box p1i2",
              "item3": "check box p1i3"
          },
          "product2": {
              "item1": "check box p2i1",
              "item2": "check box p2i2",
              "item3": "check box p2i3"
          }
      },
      "cat2": {
          "product1": {
              "item1": "check box p1i1",
              "item2": "check box p1i2",
              "item3": "check box p1i3"
          },
          "product2": {
              "item1": "check box p2i1",
              "item2": "check box p2i2",
              "item3": "check box p2i3"
          }
      }
  }
  </code></pre>
  
  <p>I have presented the data based on the category then item, so user will select category first then select items that he wants, and based on that I will filter the json file based on the selection, and then present it as form in relevant template:</p>
  
  <p>The question is since the created form is not Django Form so how I can get the posted data in the view, (there will be an input box and several check box (based on user selection)</p>
  
  <h3>views.py</h3>
  
  <pre><code>def select_cat1(request, item):
      if request.method=='POST':
          ?(how to get posted data here?)
  
      else:
       data = open(json_file).read()
          json_data = json.loads(data)
          product_list = {}
          for key in json_data.get('cat1'):
              product_list[key] = json_data['cat1'][key][item]
          return render(request, 'cat1.html', {'item': item, 'product_list': product_list })
  
  def select_cat2(request, item):
    if request.method=='POST':
          ?(how to get posted data here?)
  
      else:
       data = open(json_file).read()
          json_data = json.loads(data)
          product_list = {}
          for key in json_data.get('cat2'):
              product_list[key] = json_data['cat2'][key][item]
          return render(request, 'cat2.html', {'item': item, 'product_list': product_list })
  </code></pre>
  
  <h3>cat1.html</h3>
  
  <pre><code>{% extends 'base.html' %}
  
  
  {% block content %}
  
  &lt;form method="POST"&gt;{% csrf_token %}
      &lt;label&gt;enter your phone:&lt;/label&gt;  
      &lt;input type="text" id="mobile_number"&gt;
  
      {% for key, value in product_list.items %}
          &lt;input type="checkbox" name="{{ key }}" value="{{ key }}"&gt; {{ value }}&lt;br&gt;
      {% endfor %}
  
    &lt;button type="submit" &gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  
  {% endblock %}
  </code></pre>