Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 轻松pdf格式的Django sqlite内容_Python_Django_Sqlite_Pdf - Fatal编程技术网

Python 轻松pdf格式的Django sqlite内容

Python 轻松pdf格式的Django sqlite内容,python,django,sqlite,pdf,Python,Django,Sqlite,Pdf,Django版本:1.11.3 我已经将数据存储在sqlite数据库中,正如我希望在pdf中显示的那样。我使用easy pdf。我不知道如何在不使用render()的情况下解析数据。如何使用get_context_data()执行此操作。有什么建议吗 这项工作: def test(request): all_organizations = Organization.objects.all() all_tickets = Ticket.objects.all() context = {'all_o

Django版本:1.11.3

我已经将数据存储在sqlite数据库中,正如我希望在pdf中显示的那样。我使用easy pdf。我不知道如何在不使用render()的情况下解析数据。如何使用get_context_data()执行此操作。有什么建议吗

这项工作:

def test(request):
all_organizations = Organization.objects.all()
all_tickets = Ticket.objects.all()
context = {'all_organizations': all_organizations, 'all_tickets': all_tickets}
return render(request, 'test/docs/examples/theme/test.html', context)
不知道如何解析easy pdf中使用的所有\u组织和所有\u票据:

class HelloPDFView(PDFTemplateView):
all_organizations = Organization.objects.all()
all_tickets = Ticket.objects.all()
context = {'all_organizations': all_organizations, 'all_tickets': all_tickets}
template_name = "test/docs/examples/theme/hello.html"
def get_context_data(self, **kwargs):
    return super(HelloPDFView, self).get_context_data(
        pagesize="A4",
        title="Test",
        **kwargs
    )
试试这个,在模板中,您可以使用pagesize、title和all等键名访问数据


尝试此操作,您可以在模板中使用pagesize、title和all等键名访问数据,但这不起作用。这是否返回上下文?当它已经返回超级?不工作。这是否返回上下文?它什么时候已经回来了?
def get_context_data(self, **kwargs):
    context = super(HelloPDFView, self).get_context_data(**kwargs)
    context['all_organizations'] = Organization.objects.all() 
    context['all_tickets'] = Ticket.objects.all()
    context['pagesize']="A4"
    context['title']= 'Test'
    return context