functions.txt 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. ======================================
  2. PostgreSQL specific database functions
  3. ======================================
  4. All of these functions are available from the
  5. ``django.contrib.postgres.functions`` module.
  6. .. currentmodule:: django.contrib.postgres.functions
  7. ``TransactionNow``
  8. ==================
  9. .. class:: TransactionNow()
  10. .. versionadded:: 1.9
  11. Returns the date and time on the database server that the current transaction
  12. started. If you are not in a transaction it will return the date and time of
  13. the current statement. This is a complement to
  14. :class:`django.db.models.functions.Now`, which returns the date and time of the
  15. current statement.
  16. Note that only the outermost call to :func:`~django.db.transaction.atomic()`
  17. sets up a transaction and thus sets the time that ``TransactionNow()`` will
  18. return; nested calls create savepoints which do not affect the transaction
  19. time.
  20. Usage example::
  21. >>> from django.contrib.postgres.functions import TransactionNow
  22. >>> Article.objects.filter(published__lte=TransactionNow())
  23. <QuerySet [<Article: How to Django>]>