I have two models,
Item and Transaction
class Item(models.Model):
    id = models.AutoField(db_column='id', primary_key=True)
    name = models.CharField(max_length=48, verbose_name=_(u'Name')) 
class Transaction(models.Model):
    transactionItem = models.ForeignKey(Item, verbose_name=_(u'Transaction Item'))
    createdDate = models.DateField(default=datetime.date.today(), verbose_name=_(u'Date'))
So in db, Transaction table will contain transactions for Item.
I need to select Items which have records in transaction table before given date. If a Item has transactions before and after the given date, I need to ignore it.
EDIT: Sample Data Item Table
--------------------------
| id       | name        |
--------------------------
| 1277     | Diode       |
--------------------------
| 1278     | Resistor    |
--------------------------
Transaction Table
---------------------------------------------
| id       | transactionItem  | createdDate        |
---------------------------------------------
| 1        | 1277             | 2014-01-14  |
---------------------------------------------
| 2        | 1277             | 2014-02-09  |
---------------------------------------------
| 3        | 1278             | 2014-01-08  |
---------------------------------------------
If given date is 2014-01-13, I should only get record with id = 3 from transaction table.
How to filter the records in django? thanks.
 
    