2

我查看了具有相同问题的先前问题,但它们似乎都是由于该人构建的自定义查询。但是我的问题是 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]
4

0 回答 0