我查看过相同问题的先前问题,但它们似乎都是由于人员构建的自定义查询。不过我的问题是django给我这个错误。在我的模型中,我有2个十进制字段用于存储经度和纬度
class TBuildings(models.Model):
ixBuilding = models.AutoField(primary_key=True)
ixLocation = models.ForeignKey(TLocations, verbose_name="Location")
iBuildingNum = models.IntegerField(verbose_name="Building #")
decLatitude = models.DecimalField(max_digits=9, decimal_places=6, verbose_name="Latitude", default=Decimal('0.0000'))
decLongitude = models.DecimalField(max_digits=9, decimal_places=6, verbose_name="Longitude", default=Decimal('0.0000'))
class Meta:
db_table = "tBuildings"
verbose_name = "Building"
verbose_name_plural = "Buildings"
def __str__(self):
return "%s" % (self.iBuildingNum)
此模型已添加到我创建Building
对象的管理网站。
但每当我输入经度和纬度(56.678,-12.26520)时,它就会给我这个错误。我不知道为什么当我告诉它为小数时它甚至试图转换成文本
DatabaseError at /admin/ums/tbuildings/add/
(-2147352567, 'Exception occurred.', (0, u'Microsoft OLE DB Provider for SQL Server', u'Operand type clash: ntext is incompatible with decimal', None, 0, -2147217913), None)
Command:
SET NOCOUNT ON;DECLARE @sqlserver_ado_return_id table ([ixBuilding] int);INSERT INTO [tBuildings] ([ixLocation_id], [iBuildingNum], [decLatitude], [decLongitude]) OUTPUT INSERTED.[ixBuilding] INTO @sqlserver_ado_return_id VALUES (?, ?, ?, ?);SELECT * FROM @sqlserver_ado_return_id
Parameters:
[Name: p0, Dir.: Input, Type: adInteger, Size: -1, Value: "1", Precision: 0, NumericScale: 0, Name: p1, Dir.: Input, Type: adInteger, Size: -1, Value: "4096", Precision: 0, NumericScale: 0, Name: p2, Dir.: Input, Type: adBSTR, Size: -1, Value: "42.91899", Precision: 0, NumericScale: 0, Name: p3, Dir.: Input, Type: adBSTR, Size: -1, Value: "-81.26520", Precision: 0, NumericScale: 0]