﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24486	UnboundLocalError in db.models.expressions	Michael Angeletti	Josh Smeaton	"After filing #24485, I stumbled into a bug that is somewhat related, in the sense of its relationship to {{{output_field}}} and {{{DurationField}}} support in general. An {{{UnboundLocalError}}} occurs @ https://github.com/django/django/blob/ceaf31adfff3801f1092a215f73704e15a70e90c/django/db/models/expressions.py#L401.

I discovered this while running the following:

{{{
Ticket.objects.filter(
    active_at__lte=now,
    active_at__gt=now - models.F('duration')
)
}}}

Using the following model:

{{{
class Ticket(models.Model):
    # ... other fields omitted
    active_at = models.DateTimeField()
    duration = models.DurationField()
}}}

I've categorized this as a release blocker, because it prohibits the use of {{{DurationField}}} with {{{F}}}."	Bug	closed	Database layer (models, ORM)	1.8beta2	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
