PostgreSQL 固有のデータベース関数Link to this heading
これらの関数はすべて django.contrib.postgres.functions モジュールから利用できます。
RandomUUIDLink to this heading
- class RandomUUIDLink to this definition
バージョン 4 の UUID を返します。
使用例:
>>> from django.contrib.postgres.functions import RandomUUID
>>> Article.objects.update(uuid=RandomUUID())
TransactionNowLink to this heading
- class TransactionNowLink to this definition
現在のトランザクションが開始されたデータベースサーバー上の日時を返します。トランザクション中でない場合は、現在のステートメントの日時を返します。これは 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>]>