Skip to content

Commit

Permalink
Added view to open stock data pdf file
Browse files Browse the repository at this point in the history
  • Loading branch information
DipanshKhandelwal committed Nov 10, 2017
1 parent ecd3b21 commit 36a1a49
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sell/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.shortcuts import render
from django.shortcuts import render, HttpResponse
import os


Expand All @@ -10,3 +10,10 @@ def sell(request):
file = file[:len(file)-4]
my_list.append(file)
return render(request, 'sell/sell.html', {'go': my_list})


def open_pdf(request, slug):
with open('buy/static/pdf/'+slug+'.pdf', 'rb') as pdf:
response = HttpResponse(pdf.read(), content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename='+slug+'.pdf'
return response

0 comments on commit 36a1a49

Please sign in to comment.