如何创建报告视图以在Django rest框架视图中返回所请求示例的pdf报告

时间:2018-11-12 11:41:58

标签: django python-3.x django-rest-framework django-views

我需要创建一个Report视图以返回所请求样品的pdf报告(只是样品列表作为内容)。我该怎么做

下面是我的模型

class Patient(models.Model):
    first_name = models.CharField(max_length=25)
    last_name = models.CharField(max_length=35)
    phone = models.CharField(max_length=18)
    email = models.EmailField(unique=True)
    created_at =  models.DateTimeField(auto_now_add=True)   

class Embryo(models.Model):
     name = models.CharField(max_length=45)
     analysis_result = models.Charfield(max_length=10)
     created_at = models.DateTimeField(auto_now_add=True)
     patient = models.ForeignKey(Patient, on_delete=models.CASCADE)

以下是示例:

[
{
"name": "embryo_1",
"analysis_results": "46,XX"
},
{
"name": "embryo_2",
"analysis_results": "47,XY,+21"
},
{
"name": "embryo_3",
"analysis_results": "46,XY"
},
]

0 个答案:

没有答案