在我的模块中,我有一个实体“ Bill”,其中有两个浮点字段“ total”和“ remaining”,我希望“ remaining”从“ total”中获取其默认值。我怎样才能做到这一点? 我已经尝试过这些,但是当我尝试创建一个新的“ Bill”时,它显示错误“ TypeError:float()参数必须是字符串或数字,而不是'Float'“
total = fields.Float(string='Total', digits=(10, 2))
remaining = fields.Float(string='Remaining', digits=(10, 2) default=total)
答案 0 :(得分:1)
将它们设为def test_verified_user_uses_correct_template(self):
user = User.objects.create_superuser('username')
self.client.force_login(user)
response = self.client.get('/enrolment/')
self.assertTemplateUsed(response, 'enrolment/index.html')
,
Related field