title: How to write Foreign Key to an attribute of other model?
body: <p>I want to create a model that joins two tables in my DB. When writing the foreign keys like this:</p>
  
  <pre><code>fromnode = models.ForeignKey(znode.code)
  tonode = models.ForeignKey(znode.code)
  </code></pre>
  
  <p>there is an error: <code>type object 'znode' has no attribute 'code'</code>, but there is such an attribute in <code>znode</code>:</p>
  
  <pre><code>class znode(models.Model):
      code = models.DecimalField(max_digits=65535, decimal_places=65535, blank=True, primary_key=True)
  </code></pre>
  
  <p>How do I write this correctly?</p>