title: How to generate PDF in Django Generic Views?
body: <p>I have a template that is rendered by generic List View. I want to give a download link in front of each row of data in table. The download link will create a PDF file of respective rows data. Please tell me how to write a code for that? </p>
  
  <p>Views.py</p>
  
  <pre><code>class BookingConfirmationListView(LoginRequiredMixin, generic.ListView):
      model = container_booking
      template_name = 'home/booking_confirmation_detail.html'
      context_object_name = 'all_container'
  
      def get_queryset(self):
          return container_booking.objects.all()
  </code></pre>
  
  <p>Templates look like </p>
  
  <pre><code>&lt;table class="table-striped table-hover table-bordered" width="100%"&gt;
    &lt;tr&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;th&gt;Source&lt;/th&gt;
      &lt;th&gt;Destination&lt;/th&gt;
      &lt;th&gt;Container&lt;/th&gt;
      &lt;th&gt;Commodity&lt;/th&gt;
      &lt;th&gt;Agreed Rate&lt;/th&gt;
      &lt;th&gt;Edit&lt;/th&gt;
      &lt;th&gt;Delete&lt;/th&gt;
      &lt;th&gt;Status&lt;/th&gt;
    &lt;/tr&gt;
  {% for item in all_container %}
    &lt;tr&gt;
      &lt;td&gt;{{ item.date }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;{{ item.place_of_reciept }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;{{ item.final_place_of_destination }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;{{ item.equipment_type }}{{ item.quantity }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;{{ item.commodity }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;{{ item.agreed_rate }}&amp;nbsp;&lt;/td&gt;
      &lt;td&gt;&lt;a href="{% url 'home:cont_bk-update' item.id %}" &gt;&lt;i class="fas 
           fa-edit"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;&lt;a href="{% url 'home:cont_bk-delete' item.id %}" &gt;&lt;i class="fas 
           fa-trash"&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
      &lt;td&gt;{{ item.approved }}&lt;/td&gt;
    &lt;/tr&gt;
  {% endfor %}
  &lt;/table&gt;
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>url(r'^cont_bkdetail$', views.BookingConfirmationListView.as_view(), 
  name='cont_bk-detail'),
  url(r'^cont_bk/(?P&lt;pk&gt;[0-9]+)/$', 
  views.BookingConfirmationUpdate.as_view(), name='cont_bk-update'),
  url(r'^cont_bk/(?P&lt;pk&gt;[0-9]+)/delete/$', 
  views.BookingConfirmationDelete.as_view(), name='cont_bk-delete'),
  </code></pre>
  
  <p>I want that whenever I click download, the PDF file of that row is generated.</p>