Opened 4 years ago
Closed 4 years ago
#31755 closed Cleanup/optimization (fixed)
make temporal subtraction work without ExpressionWrapper
Reported by: | Sergey Fedoseev | Owned by: | Sergey Fedoseev |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
class Experiment(models.Model): start = models.DateTimeField() end = models.DateTimeField() Experiment.objects.annotate( delta=F('end') - F('start') + Value(datetime.timedelta(), output_field=DurationField()) )
This gives:
django.core.exceptions.FieldError: Expression contains mixed types: DateTimeField, DurationField. You must set output_field.
Change History (6)
comment:1 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 4 years ago
Triage Stage: | Unreviewed → Accepted |
---|
Hi Sergey. Thanks — yes, it would be nice it that worked.
comment:4 by , 4 years ago
Type: | Uncategorized → Cleanup/optimization |
---|
comment:5 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.