class borrow_info(models.Model):
people_id = models.BigAutoField(verbose_name='ID', primary_key=True)
people_name = models.CharField(verbose_name="姓名", max_length=32)
borrow_time = models.DateTimeField(verbose_name="借出时间", default=timezone.now)
restore_time = models.DateTimeField(verbose_name="归还时间", null=True, blank=True)
borrow_usage = models.TextField(verbose_name="借用用途", null=True, blank=True)
phone = models.IntegerField(verbose_name="设备id", unique=True, null=True, blank=True)
class Meta:
db_table = "borrow_info"
def __str__(self):
return f'{self.people_name, self.borrow_time.strftime("%Y-%m-%d"), self.restore_time.strftime("%Y-%m-%d"), self.borrow_usage}'
django用外键显示其他表数据修改__str__
最新推荐文章于 2023-03-31 22:11:51 发布