首页
随机页面
分类
查看“Django/docs/3.0.x/ref/contrib/postgres/functions”的源代码
来自菜鸟教程
Django/docs/3.0.x/ref/contrib/postgres/functions / ←
PostgreSQL 特定的数据库函数 — Django 文档
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
<div id="postgresql-specific-database-functions" class="section"> = PostgreSQL specific database functions = All of these functions are available from the <code>django.contrib.postgres.functions</code> module. <div id="randomuuid" class="section"> == <code>RandomUUID</code> == ; ''class'' <code>RandomUUID</code> : Returns a version 4 UUID. The [https://www.postgresql.org/docs/current/pgcrypto.html pgcrypto extension] must be installed. You can use the [[../operations#django.contrib.postgres.operations|<code>CryptoExtension</code>]] migration operation to install it. 使用实例: <div class="highlight-default notranslate"> <div class="highlight"> <pre>>>> from django.contrib.postgres.functions import RandomUUID >>> Article.objects.update(uuid=RandomUUID())</pre> </div> </div> </div> <div id="transactionnow" class="section"> == <code>TransactionNow</code> == ; ''class'' <code>TransactionNow</code> : Returns the date and time on the database server that the current transaction started. If you are not in a transaction it will return the date and time of the current statement. This is a complement to [[../../../models/database-functions#django.db.models.functions|<code>django.db.models.functions.Now</code>]], which returns the date and time of the current statement. Note that only the outermost call to [[../../../../topics/db/transactions#django.db.transaction|<code>atomic()</code>]] sets up a transaction and thus sets the time that <code>TransactionNow()</code> will return; nested calls create savepoints which do not affect the transaction time. 使用实例: <div class="highlight-default notranslate"> <div class="highlight"> <pre>>>> from django.contrib.postgres.functions import TransactionNow >>> Article.objects.filter(published__lte=TransactionNow()) <QuerySet [<Article: How to Django>]></pre> </div> </div> </div> </div> [[Category:Django 3.0.x 中文文档]]
返回至“
PostgreSQL 特定的数据库函数 — Django 文档
”。