title: bind csv file with django model while showing as output within html
body: <p>I have a django model and csv file separately. What I want to do is that user upload a csv file with a single colomn ('fp_Item').If colomn line exists in the django model as per below</p>
  
  <pre><code>(queryset_list.filter(
                              Q(fp_Item__contains=query)))
  </code></pre>
  
  <p>I want to retrieve the necessary fields from the database and show within html if does not exists it shouldn't retrieve anything and leave empty but still should have to print the csv file line.</p>
  
  <pre><code>def check_fp(request):
      if not request.user.is_active:
          return render(request, 'login.html')
      else:
          if request.method == 'POST' and request.FILES['csv_file2']:
              myfile = request.FILES['csv_file2']
              fs = FileSystemStorage()
              filename = fs.save(myfile.name, myfile)
              data = csv.reader(fs.open(filename, mode='r'))
              queryset_list = fp.objects.all()
              lines=[]
              for row in data:
                  if row[0] != 'fp_Item':
                      line = row[0]
                      lines.append(line)
                      query= line
                      if query:
                          queryset_list.filter(
                              Q(fp_Item__contains=query))
                          queryset_list= fp.objects.all()
                      context = {'lines': lines,
                                 'instances': queryset_list,
                                 }
                      return render(request, 'check_fp.html', context)
              context = {'lines': lines,
                         'instances': queryset_list,
                         }
              return render(request, 'check_fp.html', context)
          return render(request, 'check_fp.html', {})
  </code></pre>
  
  <p>lines.append(line) is working and writing csv column to html file but I couldn't somehow bind the django model and the csv column together. Isn't "if query" method usable for this scenario ?</p>
  
  <p>Here is my html file:  I want to match line at retrieve description and detail,timestamp and updated fields from the database. Am I looping false here ?</p>
  
  <pre><code>                        &lt;tbody&gt;
                  {% for line in lines %}
                  {% for instance in instances %}
                          &lt;tr&gt;
                              &lt;td width="25%&gt;
                                  &lt;a href="#"&gt;  {{ line }} &lt;/a&gt;
                              &lt;/td&gt;&lt;/tr&gt;
                              &lt;td&gt;
                                  {{ instance.description }}
                              &lt;/td&gt;
                              &lt;td&gt;
                                  {{ instance.detail }}
                              &lt;/td&gt;
                              &lt;td width="180"&gt;
                                  {{ instance.timestamp }}
                              &lt;/td&gt;
                              &lt;td width="180"&gt;
                                  {{ instance.updated }}
                              &lt;/td&gt;
                              &lt;td width="200"&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;{% endfor %} {% endfor %}
                  &lt;/tbody&gt;
              &lt;/table&gt;
  </code></pre>