title: Django - Filter objects older than X days
body: <p>I need to filter objects older than <code>X</code> number of days. I realize this question exists here: <a href="https://stackoverflow.com/questions/1984047/django-filter-older-than-days">django filter older than day(s)?</a></p>
  
  <p>However, I not trying to do exactly that, since the number of days, in my case lives inside the model:</p>
  
  <pre><code>class Post(models.Model):
      title = models.CharField(max_length=200)
      description = models.CharField(max_length=500)
      createdAt = models.DateTimeField(default=datetime.now, blank=True)
      plan = models.ForeignKey(Plan) # This model has the number of days
  </code></pre>
  
  <p>This is the query I have so far:</p>
  
  <p><strong>EDIT</strong>: I changed the days.plan part for <code>the_post.plan.days</code> Meaning that the number of days that I'm using to compare is in each post's <code>plan</code> field.</p>
  
  <pre><code>    Post.objects.filter(createdAt__lte=datetime.now() - timedelta(days=the_post.plan.days))
  </code></pre>
  
  <p>Note the <code>plan.days</code> part of the query. How can I reference <code>the_post.plan.days</code> for this query? Is it possible?</p>