class order(models.Model): """ 订单表 """ title = models.ForeignKey(to="task",verbose_name="任务标题") publisher = models.ForeignKey(to="UserInfo",related_name=‘publisher_id‘,verbose_name="发布者") money = models.IntegerField(verbose_name="悬赏虚拟币") receiver = models.ForeignKey(to="UserInfo",related_name=‘receiver_id‘,verbose_name="接单者") check_status = models.BooleanField(verbose_name="审核状态",default=0) status = models.BooleanField(verbose_name="完成状态",default=0) name = models.CharField(max_length=255,verbose_name="文件名",null=True) file_path = models.CharField(max_length=255,verbose_name="文件存放路径",null=True) create_time = models.DateTimeField(auto_now=True,verbose_name="创建时间") def __str__(self): return self.title def download(self): path = self.file_path button_html = "<a href=‘{}‘>下载文件</a>".format(path) return format_html(button_html) download.short_description = format_html("""<a href=‘#‘ style="position: relative;left: -12px;">下载文件</a>""") class Meta: verbose_name = "订单表" verbose_name_plural = verbose_name db_table = ‘order‘
原文:https://www.cnblogs.com/wanghong1994/p/12879157.html