Debian Codegraph @

docs/ref/contrib/postgres/functions.txt

raw
1 ======================================
2 PostgreSQL specific database functions
3 ======================================
4
5 All of these functions are available from the
6 ``django.contrib.postgres.functions`` module.
7
8 .. currentmodule:: django.contrib.postgres.functions
9
10 ``RandomUUID``
11 ==============
12
13 .. class:: RandomUUID()
14
15 Returns a version 4 UUID.
16
17 Usage example:
18
19 .. code-block:: pycon
20
21 >>> from django.contrib.postgres.functions import RandomUUID
22 >>> Article.objects.update(uuid=RandomUUID())
23
24 ``TransactionNow``
25 ==================
26
27 .. class:: TransactionNow()
28
29 Returns the date and time on the database server that the current transaction
30 started. If you are not in a transaction it will return the date and time of
31 the current statement. This is a complement to
32 :class:`django.db.models.functions.Now`, which returns the date and time of the
33 current statement.
34
35 Note that only the outermost call to :func:`~django.db.transaction.atomic()`
36 sets up a transaction and thus sets the time that ``TransactionNow()`` will
37 return; nested calls create savepoints which do not affect the transaction
38 time.
39
40 Usage example:
41
42 .. code-block:: pycon
43
44 >>> from django.contrib.postgres.functions import TransactionNow
45 >>> Article.objects.filter(published__lte=TransactionNow())
46 <QuerySet [<Article: How to Django>]>