小编Юра*_*лян的帖子

Django 查询集返回 DurationField 值(以秒为单位)

我有两个模型:PostComment(评论与帖子有 FK 关系)。

现在我想返回所有帖子及其“响应时间”。我以格式得到此响应时间timedelta。我可以在几秒钟内收到它吗?我尝试过ExtractSecond,但这不是我想要的:

base_posts_queryset.annotate(
    min_commnet_date=Min("comment_set__date_created"),
    response_time=ExpressionWrapper(F("min_commnet_date") - F("date_created"), output_field=DurationField()),
    response_time_in_sec=ExtractSecond(F("response_time"))
).filter(response_time__isnull=False).values("response_time", "response_time_in_sec")
Run Code Online (Sandbox Code Playgroud)

此代码返回以下对象:

{'response_time': datetime.timedelta(days=11, seconds=74024, microseconds=920107), 'response_time_in_sec': 44}
Run Code Online (Sandbox Code Playgroud)

我想要实现的基本上是调用.seconds结果查询集中的每个项目。我可以在 python 中执行此操作,但是 mb 它可以在数据库级别上完成吗?

python django postgresql django-orm

3
推荐指数
1
解决办法
2972
查看次数

无法将 AWS SES 配置为从 Cognito 发送电子邮件

我已经创建了一个 SES 帐户并且我已经在孟买地区验证了我的域。

现在在 Cognito 中管理选项卡“消息自定义”上的用户池,我正在尝试配置 Cognito+SES。但是在“ SES 地区”领域,没有孟买地区(只有弗吉尼亚州、俄勒冈州、爱尔兰)。因此我不能选择“ FROM email address ARN ”。

我做错了什么?或者我缺少什么?

amazon-web-services amazon-ses amazon-cognito

2
推荐指数
1
解决办法
1303
查看次数