title: How to get attribute of a django model's foreign key object using getattr in python?
body: <p>Suppose I have two models as such </p>
  
  <pre><code>class first(models.Model):
      name = models.CharField(max_length=20)
      y = models.ForeignKey(second)
  
  class second(models.Model):
      random = models.CharField(max_length=20)
  </code></pre>
  
  <p>Now if I want value of <code>name</code> for a <code>first</code> object instance using <code>getattr</code>, I can do <code>getattr(x, 'name')</code> where <code>x</code> is a <code>first</code> object but if I try the same with <code>getattr(x, 'y.random')</code> , it throws me an error even though <code>x.y.random</code> is a totally valid query. </p>
  
  <p>Is it possible to query <code>x.y.random</code> if all I have is object <code>x</code> and string 'y.random'? </p>