創建在Django的模型,我需要做出獨特的兩個整型字段的組合:Django的unique_together不起作用:「指的是不存在的領域」
class example(models.Model):
lenght = models.PositiveSmallIntegerField
position = models.PositiveSmallIntegerField
otherfield = models.ForeignKey('onetable')
otherfield2 = models.ForeignKey('anothertable')
class Meta:
unique_together = (("lenght", "position"),)
所以,當我同步數據庫I收到以下錯誤信息:
執行manage.py執行syncdb SystemCheckError:系統檢查發現了一些問題:
ERRORS:
prj.CodeBlock: (models.E012) 'unique_together' refers to the non-existent field 'lenght'.
prj.CodeBlock: (models.E012) 'unique_together' refers to the non-existent field 'position'.
The Python REPL process has exited
>>>
我看看I C焊割爲「charfield」字段類型我沒有收到任何錯誤消息:
class example(models.Model):
lenght = models.CharField(max_length=8)
position = models.CharField(max_length=8)
otherfield = models.ForeignKey('onetable')
otherfield2 = models.ForeignKey('anothertable')
class Meta:
unique_together = (("lenght", "position"),)
爲什麼我不能讓唯一的整數字段的組合?