We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using this field is not possible to direcly use the Django ORM function Extract (and similars).
Extract
Since this function checks field type before passing to database:
ValueError: Extract input expression must be DateField, DateTimeField, TimeField, or DurationField.
This does not allow the developer to use with ease the postgres DB function EXTRACT.
EXTRACT
The text was updated successfully, but these errors were encountered:
A workaround for this is to use ExpressionWrapper:
ExpressionWrapper
from django.db.models import DurationField, ExpressionWrapper, F from django.db.models.functions import Extract MyModel.objects.annotate( epoch=Extract( ExpressionWrapper(F('myfield'), DurationField()), 'epoch', ), )
Sorry, something went wrong.
No branches or pull requests
When using this field is not possible to direcly use the Django ORM function
Extract
(and similars).Since this function checks field type before passing to database:
This does not allow the developer to use with ease the postgres DB function
EXTRACT
.The text was updated successfully, but these errors were encountered: