我正在使用 django-filter ,需要ChoiceFilter根据我收到的请求添加一个选项。我正在阅读 ChoiceFilter 的文档,但它说:This filter matches values in its choices argument. The choices must be explicitly passed when the filter is declared on the FilterSet。
那么有什么方法可以在 中获得依赖于请求的选择吗ChoiceFilter?
我实际上还没有编写代码,但以下是我想要的 -
class F(FilterSet):
status = ChoiceFilter(choices=?) #choices depend on request
class Meta:
model = User
fields = ['status']
Run Code Online (Sandbox Code Playgroud) 我有一个 Postgres db,其中OrderedDict已保存为字符串。我需要将此字符串转换为 json/dict,以便将其保存在 JSONField 中。如何将此字符串转换为dict?
字符串示例 -
OrderedDict([('order_id', 'xxxxxx'), ('tracking_id', 'xxxxxx'), ('bank_ref_no', 'xxxxx'), ('order_status', 'Success')])
Run Code Online (Sandbox Code Playgroud)
我试过了,json.loads(string)但它给出了解码错误。除了手动解析字符串之外还有其他解决方案吗?
我想在上传视频文件 (.mp4) 时使用 S3 事件发布到 AWS Lambda,以便对其进行压缩。问题是视频文件的路径存储在RDS中,所以我希望压缩后路径保持不变。据我所知,替换文件将再次调用Object Created导致无限循环的事件。
有没有办法在不触发任何事件的情况下替换文件?我有什么选择?
python ×2
amazon-s3 ×1
aws-lambda ×1
choicefield ×1
django ×1
filter ×1
json ×1
ordereddict ×1