代码之家  ›  专栏  ›  技术社区  ›  Cheok Yan Cheng

在Postgres中,如何在没有明确提及小数位数和最大位数的情况下使用十进制字段

  •  1
  • Cheok Yan Cheng  · 技术社区  · 6 年前

    我计划在Postgres中使用下表

    create table Transaction (
        tax_amount decimal
    );
    

    对于Django模型,我使用

    tax_amount = models.DecimalField(blank=True, null=True)
    

    我犯了个错误

    billing.Transaction.tax_amount: (fields.E130) DecimalFields must define a 'decimal_places' attribute.
    billing.Transaction.tax_amount: (fields.E132) DecimalFields must define a 'max_digits' attribute.
    

    我在想,我怎么能把Django翻译成与postgressql等价的语言呢 decimal_places max_digits 明确地?

    0 回复  |  直到 6 年前