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

2024-09-25 08:42:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我计划在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_placesmax_digits?你知道吗


Tags: djangotruefieldsattributeamountmaxtransactiondecimal