我在models.py中更新了模型,但是迁移告诉我没有检测到任何更改。 所以我清理了'django_migrations'表中的所有数据。 并且模型表下垂。
然后我迁移了一个空的迁移,这没有问题。但是当我迁移一个新的makemigrations时终端显示'1054错误'。
关于django迁移到底是怎么回事?
class Platform(models.Model):
name = models.CharField(max_length=60, blank=True, null=False)
token = models.CharField(max_length=30, blank=True, null=False)
hostname = models.CharField(max_length=20, blank=True, null=False)
# stationmac = models.CharField(max_length=20, blank=True, null=False)
# stationip = models.CharField(max_length=20, blank=True, null=False)
class Meta:
managed = True
class Reservation(models.Model):
user = models.ForeignKey(User)
platform = models.ForeignKey(Platform)
title = models.CharField(max_length=50, blank=True)
starttime = models.DateTimeField(auto_now=False, blank=True, null=False)
endtime = models.DateTimeField(auto_now=False, blank=True, null=False)
createtime = models.DateTimeField(auto_now=True, blank=True, null=False)
isstop = models.BooleanField(default=False, null=False)
class Meta:
managed = True
@property
def isexpire(self):
return timezone.now() > self.endtime
@property
def isactive(self):
return self.starttime <= timezone.now() <= self.endtime
@property
def status(self):
if self.isstop:
return "Stop"
elif self.isactive:
return "Progress"
elif self.isactive is False and self.isexpire is False:
return 'Waiting'
else:
return 'Finished'