title: Changing the behaviour of a Django model with __getattr__
body: <p>I'm trying to change the behaviour of a Django model to allow me to access a foreign key's properties directly from the parent, e.g.</p>
  
  <pre><code>cache.part_number  
  vs  
  cache.product.part_number
  </code></pre>
  
  <p>I've tried overriding the <code>__getattr__</code> method as follows, but I get a recursion error when I try to access the foreign key's properties</p>
  
  <pre><code>class Product(models.Model):
      part_number = models.CharField(max_length=10)
      ...
  
  class Cache(models.Model):
      product = models.ForeignKey(Product)
      ...
  
      def __getattr__(self, name):
          value = getattr(self.product, name, None)
          if value:
              return value
          else:
              raise AttributeError
  </code></pre>
  
  <p>What am I doing wrong?</p>