【发布时间】:2020-10-12 03:34:40
【问题描述】:
在views.py中:
c = canvas.Canvas(str(num)+'.pdf')
c.setPageSize((page_width, page_height))
c.drawInlineImage('logo.jpg', margin, page_height - image_height - margin,
image_width, image_height)
c.setFont('Arial', 80)
text = 'INVOICE'
c.save()
tt2 = Invoices_list.objects.all().filter(Number=num)
tt2.update(document=c)
在models.py中:
class Invoices(models.Model):
Date = models.DateTimeField()
Name = models.CharField(max_length=100, blank=True, null=True)
document = models.FileField(upload_to='temp/', blank=True, null=True)
我的视图创建了一条记录并完成了日期和名称记录,然后我创建了工作正常的 pdf(可以在我的根目录中看到它)但是我如何将它作为 tt2.update(document =c) 生成文件名“
任何
【问题讨论】:
标签: django pdf reportlab filefield