this is my image tag in django templates
<img src="{{post.image.url}}" />
my url.py
path(
'pdf/<int:pk>/',
MyPDF.as_view(template_name='templates/post_detail.html',
filename='post_pdf.pdf'),
name='pdf-wk'
),
this is my view.py
class MyPDF(PDFTemplateView):
template_name = 'templates/post_detail.html'
def get_context_data(self, pk):
context = {'post': Post.objects.get(pk=pk)}
return context
CodePudding user response:
i was having the same issue i installed wkhtmltopdf in my env by using
sudo apt-get install wkhtmltopdf
if this doesn't work reinstall wkhtmltopdf after that check your settings.py
MEDIA_ROOT = 'blog4/media'
change this line to this.
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
this may work!