我在我的django应用程序live_from和live_to中有字段,这些字段是非必填的。当此字段为空时,我的方法中会出现错误:
字段:
live_from = models.DateTimeField('live from', blank=True, null=True)
live_to = models.DateTimeField('live to', blank=True, null=True)下面是我的方法:
def is_live(self):
return (self.live_from <= timezone.now()) and (self.live_to >= timezone.now())错误:TypeError: unorderable types: NoneType() <= datetime.datetime()
https://stackoverflow.com/questions/41261057
复制相似问题