title: Best practices for Django model lookup
body: <p>I've got a Django models.py which declares a bunch of different classes, including some abstract, and they're related to each other via a variety of ForeignKey, OneToOne, and <a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#ref-manytomany" rel="nofollow">ManyToMany</a> relationships. Some of the models imply interactions with other machines - so I use Django's <a href="https://docs.djangoproject.com/en/dev/topics/signals/" rel="nofollow">signals</a> to watch changes to the relevant models, and inform remote machines of changes that effect them. So far, so good.</p>
  
  <p>Since there are a bunch of signals and a bunch of models, I've put the signals in a separate file (signals.py), and defined a couple of functions to register &amp; unregister them as a group. The end of models.py just calls the <code>register_all()</code> and everything happens automagically. If something needs to happen <em>without</em> sending the remote signals (e.g. unit tests), I can call <code>unregister_all()</code> before hand, then <code>register_all()</code> once I'm done with the weird block. I like splitting the signals from the models because it makes it easier for a programmer to find what she's looking for.</p>
  
  <p>This does, however, lead to some oddness with referencing the models in signals.py, since I occasionally need to traverse a few relationships. The signals take arguments <code>(sender, **kwargs)</code>, and (depending on the signal), <code>kwargs</code> can include items "instance" and/or "model". Still good - this gives my code a solid starting point for any lookups it needs to do.</p>
  
  <p>Now, to the actual question: Is there a preferred way to chain 3-5 steps away? I have a choice between patterns <code>get_model('myapp', 'MyModel')</code> and <code>MyModel = sender.parent.field.rel.to</code>, both of which work fine. Is there a reason to choose one over the other? I'd like to maximize code readability and make the changes as easy as possible if relationships or model names change.... And of course, fast &amp; reliable operation is preferred.</p>