[英]Django refuses to accept my one-off default value for FloatField
I have a class and I'm trying to add a new FloatField
to it. 我有一个类,我正在尝试添加一个新的
FloatField
。 Django wants a default value to populate existing rows (reasonable). Django想要一个默认值来填充现有的行(合理的)。 However, it refuses to accept any value I give it.
但是,它拒绝接受我给它的任何价值。
You are trying to add a non-nullable field 'FIELDNAME' to CLASS without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit, and let me add a default in models.py
Select an option: -1
Please select a valid option: -1
Please select a valid option: -1
Please select a valid option: float(-1)
Please select a valid option: -1.0
Please select a valid option: float(-1.0)
Please select a valid option:
How do I get it to accept my value? 我如何让它接受我的价值?
You should select option 1 and then input your value 您应该选择选项1,然后输入您的值
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit, and let me add a default in models.py
1
After selecting 1. It would ask to provide your default value. 选择1后,它会要求提供您的默认值。
Please enter the default value now, as valid Python
The datetime and django.utils.timezone modules are available, so you can do e.g. timezone.now()
>>> -1.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.