如果这是我的模型:
class Bid(models.Model):
amount = models.DecimalField(max_digits=11, decimal_places=2)
starting_bid = models.DecimalField(max_digits=11, decimal_places=2, null=True)
Run Code Online (Sandbox Code Playgroud)
如何添加一个约束来检查金额字段是否大于或等于起始出价?这就是我现在所拥有的:
class Meta:
constraints = [
models.CheckConstraint(check=Q(amount > starting_bid), name='amount_gte_starting_bid')
]
Run Code Online (Sandbox Code Playgroud)
这当然是不正确的。谢谢你!
我正在尝试将js-search npm 包导入到我的客户端.js文件中。他们的文档说要写import * as JsSearch from \'js-search\';,但是,这给了我一个Uncaught TypeError: Failed to resolve module specifier "js-search". Relative references must start with either "/", "./", or "../".. 我尝试配置相对路径很长一段时间,但最终我发现它\'js-search\'指的是包名,而不是目录。那么,我一定缺少一些允许我使用此导入行的依赖项?谢谢。
编辑:目录结构:
\nmyproject\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 myproject\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 node_modules\\js-search\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 myapp\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 static\\myapp\n \xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 myapp.js\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 templates\\search\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.html\nRun Code Online (Sandbox Code Playgroud)\n编辑:可能是因为我在本地主机上运行而不是在服务器上运行吗?
\n