带时区的时间戳,使用 django ORM 未知

Timestamp with time zone, unknown using django ORM

从 MariaDB 转移到 postgres-10 后,出现以下错误 我正在使用 Django-orm

function date_format(timestamp with time zone, unknown) does not exist LINE 1: SELECT (DATE_FORMAT(created_at,'%h %p')) AS "in_hours", SUM(...

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Model.objects.filter(franchise=franchise)\
             .filter(created_at__date=date)\
             .extra(select={'in_hours': "DATE_FORMAT(created_at,'%%h %%p')"}) \
             .values('in_hours')\
             .order_by('created_at__hour')\
             .annotate(total_amount=Sum('amount'))

谁能解释一下哪里出了问题。 谢谢

Postgres中没有DATE_FORMAT函数,必须使用TO_CHAR https://www.postgresql.org/docs/9.1/functions-formatting.html