I ve created a view to generate a doc with docxtpl
, for this I use this view bellow but the annotate with Floatfield
doesnt work, can you help me please ?
def postACD(request, id):
Raison_sociale = Client.objects.filter(id=id).values_list('Raison_sociale',flat=True).annotate(Raison_sociale_as_float=Cast('Raison_sociale', output_field=FloatField())).get()
byte_io = BytesIO()
tpl = DocxTemplate(os.path.join(settings.MEDIA_ROOT, 'ACD.docx'))
context = {}
context['Raison_sociale'] = Raison_sociale
tpl.render(context)
tpl.save(byte_io)
byte_io.seek(0)
return FileResponse(byte_io, as_attachment=True, filename=f'ACD{id}.docx')
you can see the message error :
i have tried many solutions but nothing worked so far