📜  django models.py 将 DateTimeField 转换为 DateField - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:17.780000             🧑  作者: Mango

代码示例1
# Add a method to your model class 
# call it like any other field in your template
class Yourclass(models.Model):
    date_field = models.DateTimeField()
    def date_trunc_field(self):
        return self.date_field.date()