How can i display my data in database and export it to pdf -Django
<p>my x variable is getting all the data in my database, i guess? someone help me how can i display all data and export it to pdf file.</p>

<pre><code>response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="WishList.pdf"'

buffer = BytesIO()

# Create the PDF object, using the BytesIO object as its "file."
p = canvas.Canvas(buffer)
x = Item.objects.all()

p.drawString(100, 100,x)

p.drawString(200,300,"sad")

# Close the PDF object cleanly.
p.showPage()
p.save()

# Get the value of the BytesIO buffer and write it to the response.
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
return response
</code></pre>

<p>Your Variable x won't return anything you can print into the PDF, because its a querryset and not a couple strings attached to each other. I just started working with Django and getting the values works something like this:</p>

<pre><code>x = Item.objects.all[0].name
</code></pre>

<p>This Code snippet will asigne the vale of the row name of the first entry in your Item table to the variable x.
For more Information I can only recommend reading the 
   <a href="https://docs.djangoproject.com/en/1.10/topics/db/queries/#limiting-querysetshttp://" rel="nofollow">Tutorial about making queries</a> on the django website.</p>

python django django-models django-views