class Now
[source]
New in Django 1.9.
Returns the database server’s current date and time when the query is executed, typically using the SQL CURRENT_TIMESTAMP
.
Usage example:
>>> from django.db.models.functions import Now >>> Article.objects.filter(published__lte=Now()) <QuerySet [<Article: How to Django>]>
PostgreSQL considerations
On PostgreSQL, the SQL CURRENT_TIMESTAMP
returns the time that the current transaction started. Therefore for cross-database compatibility, Now()
uses STATEMENT_TIMESTAMP
instead. If you need the transaction timestamp, use django.contrib.postgres.functions.TransactionNow
.
Please login to continue.