在它变得非常混乱之后,我决定从头开始重新启动我的数据库。所以我删除了数据库,现在尝试用syncdb重新创建它。正如您在下面看到的那样,它正在创建表 wood_management,因为它在木材管理中找不到 wood_uuid,所以它在该表中翻倒了。但是,它还没有进行木材管理,所以我很困惑。
Creating table timber_measurement
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "c:\python26\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager
utility.execute()
File "c:\python26\lib\site-packages\django\core\management\__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\python26\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "c:\python26\lib\site-packages\django\core\management\base.py", line 220, in execute
output = self.handle(*args, **options)
File "c:\python26\lib\site-packages\django\core\management\base.py", line 351, in handle
return self.handle_noargs(**options)
File "c:\python26\lib\site-packages\django\core\management\commands\syncdb.py", line 99, in handle_noargs
cursor.execute(statement)
File "c:\python26\lib\site-packages\django\db\backends\util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "c:\python26\lib\site-packages\django\db\backends\sqlite3\base.py", line 200, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: table timber_measurement has no column named timber_uuid
姜戈模型:
class TimberMeasurement(models.Model):
uuid = UUIDField(primary_key=True)
timber = models.ForeignKey(Timber, db_column='timber_uuid',null=True, blank=True, editable=False)
measurement_value = models.FloatField(null=True, blank=True)
measurement_type = models.IntegerField(null=True, blank=True, choices=MEASUREMENT_TYPE, editable=False)
class Meta:
app_label = 'boughtin'
db_table = 'timber_measurement'
unique_together = ('timber', 'measurement_value', 'measurement_type')