title: How to access Foreign key models with custom primary key in django
body: <p>These are my two models:</p>
  
  <p>In models.py</p>
  
  <pre><code>class Person(models.Model):
  
      person_no = models.IntegerField(max_length=10, primary_key='True')
      phone = models.IntegerField(max_length=20)
  
      class Meta:
          db_table = 'person'
  
  class person_ext(models.Model):
  
      person_no = models.ForeignKey(Person)
      key = models.CharField(max_length=64)
      value = models.TextField()
  
      class Meta:
          db_table = 'personExt'
  </code></pre>
  
  <p>I went to manage.py shell to test my model and I tried to access the cell_phone of a person given the person's id this way:</p>
  
  <pre><code>        p = Person.objects.get(pk=1)
          cell_phone = Person_ext.objects.get(person_no=p).filter(key='cell').value
  </code></pre>
  
  <p>However, I'm getting the following error:</p>
  
  <p><code>DatabaseError: (1054, "Unknown column 'personExt.person_no_id' in 'field list'")</code></p>
  
  <p>My database column is just "person_id" but django is looking for "person_no_id". What do I have to do to access the personExt data using a person_no from person.</p>