title: django model foreign key queryset selecting related fields
body: <p>I am trying to select from the join of the two related tables in DJango as shown below. But I am not able get the field <code>name</code> of the other table.</p>
  
  <p>In SQL we can write:</p>
  
  <pre><code>select person.phonenumber,membership.* from membership where person=name ;
  </code></pre>
  
  <p>This displays all the <code>membership</code> fields along with <code>phonenumber</code>, but in Django it throws error: </p>
  
  <blockquote>
    <p>Cannot resolve keyword 'phonenumber' into field</p>
  </blockquote>
  
  <p>I have even tried with <code>select_related</code> but no use. Am I doing anything wrong?</p>
  
  <p><strong>model.py:</strong></p>
  
  <pre><code>from django.db import models
  
  # Create your models here.
  class Person(models.Model):
      name = models.CharField(primary_key=True,max_length=128)
      phonenumber = models.CharField(max_length=128)
      city = models.CharField(max_length=128)
  
  
      def __unicode__(self):
          return self.name
  
  class Membership(models.Model):
      person = models.ForeignKey(Person)
      date_joined = models.DateField()
      invite_reason = models.CharField(max_length=64)
  
  
  &gt;&gt;&gt; print m.query
  SELECT `myapp_membership`.`id`, `myapp_membership`.`person_id`, `myapp_membership`.`date_joined`, `myapp_membership`.`invite_reason` FROM `myapp_membership` WHERE `myapp_membership`.`person_id` = x 
  &gt;&gt;&gt; m=Membership.objects.filter(person__name='x').select_related()
  &gt;&gt;&gt; print m.query
  SELECT `myapp_membership`.`id`, `myapp_membership`.`person_id`, `myapp_membership`.`date_joined`, `myapp_membership`.`invite_reason`, `myapp_person`.`name`, `myapp_person`.`phonenumber`, `myapp_person`.`city` FROM `myapp_membership` INNER JOIN `myapp_person` ON (`myapp_membership`.`person_id` = `myapp_person`.`name`) WHERE `myapp_membership`.`person_id` = x 
  &gt;&gt;&gt; m=Membership.objects.filter(person__name='x').values('person','phonenumber').select_related()
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python2.6/dist-packages/Django-1.2.4-py2.6.egg/django/db/models/query.py", line 510, in values
      return self._clone(klass=ValuesQuerySet, setup=True, _fields=fields)
    File "/usr/local/lib/python2.6/dist-packages/Django-1.2.4-py2.6.egg/django/db/models/query.py", line 766, in _clone
      c._setup_query()
    File "/usr/local/lib/python2.6/dist-packages/Django-1.2.4-py2.6.egg/django/db/models/query.py", line 889, in _setup_query
      self.query.add_fields(self.field_names, False)
    File "/usr/local/lib/python2.6/dist-packages/Django-1.2.4-py2.6.egg/django/db/models/sql/query.py", line 1537, in add_fields
      "Choices are: %s" % (name, ", ".join(names)))
  FieldError: Cannot resolve keyword 'phonenumber' into field. Choices are: date_joined, id, invite_reason, person
  </code></pre>