Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 函数UNIX\u时间戳不存在_Django_Postgresql_Django Models - Fatal编程技术网

Django 函数UNIX\u时间戳不存在

Django 函数UNIX\u时间戳不存在,django,postgresql,django-models,Django,Postgresql,Django Models,我正在尝试将datetime转换为unix时间戳。我试过几种方法,错误都是一样的。我不太确定我该做什么 加入日期是这样的2017-09-30 10:24:44.954981+00:00 function unix_timestamp(timestamp with time zone) does not exist HINT: No function matches the given name and argument types. You might need to add explicit

我正在尝试将datetime转换为unix时间戳。我试过几种方法,错误都是一样的。我不太确定我该做什么

加入日期是这样的2017-09-30 10:24:44.954981+00:00

function unix_timestamp(timestamp with time zone) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.


User.objects.annotate(photo_time=Func(F('date_joined'),function='UNIX_TIMESTAMP'))
User.objects.extra(select={'photo_time':"to_unixtime(date_joined)"})
#also tried and UNIX_TIMESTAMP

那是因为博士后不允许你这么做()。如果确实不需要
UNIX\u时间戳
,则需要


当然,您也可以定义
到UNIXTIME
存储过程/函数,但这似乎有点过头了。

这是因为Postgres不允许您这么做()。如果确实不需要
UNIX\u时间戳
,则需要

当然,您也可以定义一个
TO_UNIXTIME
存储过程/函数,但这似乎有点过头了

User.objects.annotate(photo_time=Extract('date_joined', 'epoch').get())