I want to add the option to convert my HTML with information in to a MS word document docx.
I have the PDF with some CSS:
<h1>
{{ info.businessName }}<br />
<small style="color: rgb(187, 187, 184); margin: 0px 0px 0px 0px"
>Business Plan
<br />
Prepared {{ info.date_posted|date:"F Y" }}
</small>
</h1>
Here is the views.py
def order_word(request, info_id):
info = get_object_or_404(Info, id=info_id)
html = render_to_string('businessplan/word.html', {'info': info})
response = HttpResponse(content_type='application/word')
response['Content-Disposition'] = 'attachment; filename="{}-Business Plan.pdf"'.format(info.businessName)
return response
Here is the URL.py
path('<str:info_id>/word/', order_word, name='order_word'),
Here is the link to download the word:
<a href="{% url 'businessplan:order_word' form.instance.id %}">
<button type="button" class="btn btn-primary">
Download Word
</button>
</a>