title: Why is getattr() throwing an exception when an attribute doesn't exist?
body: <p>This one has me baffled. Consider the following Django models - representing zookeepers and the cages at the zoo that they are responsible for cleaning:</p>
  
  <pre><code>class Zookeeper(moodels.Model):
      name = models.CharField(max_length=40)
  
  class Cage(models.Model):
      zookeeper = models.ForeignKey(Zookeeper)
  </code></pre>
  
  <p>Now suppose I want to connect a receiver to the <code>Cage</code>'s <code>post_init</code> signal:</p>
  
  <pre><code>@receiver(models.signals.post_init, sender=Cage)
  def on_cage_init(instance, **kwargs):
      print instance.zookeeper
  </code></pre>
  
  <p>As expected, this raises an exception since the <code>Cage</code> has not yet been assigned to a <code>Zookeeper</code>. Consider the following modification to the body of the receiver:</p>
  
  <pre><code>print getattr(instance, 'zookeeper', 'No Zookeeper')
  </code></pre>
  
  <p>One would expect this to print "No Zookeeper" since one has not been assigned to the instance. Instead, an exception is raised:</p>
  
  <pre><code>Traceback (most recent call last):
    File "../zoo/models.py", line 185, in on_cage_init
      print getattr(instance, 'zookeeper', 'No Zookeeper')
    File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 324, in __get__
      "%s has no %s." % (self.field.model.__name__, self.field.name))
  DoesNotExist: Cage has no zookeeper.
  </code></pre>
  
  <p>Why is it raising an exception? Isn't <code>getattr()</code> supposed to return the provided default value if the attribute does not exist? I can prove that the attribute does not exist with:</p>
  
  <pre><code>print hasattr(instance, 'zookeeper')
  </code></pre>
  
  <p>...which prints <code>False</code>.</p>