PostgreSQL 固有のデータベース関数¶
これらの関数はすべて django.contrib.postgres.functions モジュールから利用できます。
RandomUUID¶
バージョン 4 の UUID を返します。
使用例:
>>> from django.contrib.postgres.functions import RandomUUID
>>> Article.objects.update(uuid=RandomUUID())
TransactionNow¶
現在のトランザクションが開始されたデータベースサーバー上の日時を返します。トランザクション中でない場合は、現在のステートメントの日時を返します。これは django.db.models.functions.Now を補完するもので、現在のステートメントの日時を返します。
Note that only the outermost call to atomic()
sets up a transaction and thus sets the time that TransactionNow() will
return; nested calls create savepoints which do not affect the transaction
time.
使用例:
>>> from django.contrib.postgres.functions import TransactionNow
>>> Article.objects.filter(published__lte=TransactionNow())
<QuerySet [<Article: How to Django>]>