python – PostgreSQL NUMERIC数据类型的Django模型字段

我正在使用Django创建一个需要列数字(15,6)的应用程序(使用PostgreSQL),但我找不到这样做的方法. 最佳答案 来自PostgreSQL文档:

The types decimal and numeric are equivalent. Both types are part of the SQL standard.

所以你可以使用Django的DecimalField

class MyModel(models.Model):
    my_field = models.DecimalField(max_digits=15, decimal_places=6)

一些文档:

> http://www.postgresql.org/docs/current/interactive/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL
> https://docs.djangoproject.com/en/1.8/ref/forms/fields/#decimalfield

点赞