title: How to write joins in django?
body: <p>How to write joins in django,i have gone through below django documentation ,but joins are not working for my model</p>
  
  <p><a href="http://docs.djangoproject.com/en/1.2/topics/db/queries/#lookups-that-span-relationships" rel="nofollow">http://docs.djangoproject.com/en/1.2/topics/db/queries/#lookups-that-span-relationships</a></p>
  
  <p>and models/many_to_many/</p>
  
  <p>and some blogs</p>
  
  <p>My Model :</p>
  
  <pre><code>class Profile(models.Model):
       name = models.CharField(max_length=50, primary_key=True)
       assign = models.CharField(max_length=50)
       doj = models.DateField()
       dob = models.DateField()
  
       class Meta:
          db_table = u'profile'
  
       def __str__(self):
           return  '%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob)
  
       def __unicode__(self):
           return  u'%s %s %s %s' % ( self.name,self.assign,self.doj,self.dob)
  
  
       enter code here
  
  class working(models.Model):
     w_name =models.ForeignKey(Profile, db_column='w_name')
     monday =  models.IntegerField(null=True, db_column='monday', blank=True)
     tuesday =  models.IntegerField(null=True, db_column='tuesday', blank=True)
     wednesday =  models.IntegerField(null=True, db_column='wednesday', blank=True)
  
     class Meta:
          db_table = u'working'
  
     def __str__(self):
           return  '%s %s %s %s' % ( self.w_name,self.monday,self.tuesday,self.wednesday)
  
     def __unicode__(self):
           return  u'%s %s %s %s' % ( self.w_name,self.monday,self.tuesday,self.wednesday)
  </code></pre>
  
  <p>I am trying to do join between two tables profile and workingday</p>
  
  <pre><code>like m=working.objects.filter(name='sushanth').select_related()
  </code></pre>
  
  <p>if i run above query i'll get</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 129, in filter
      return self.get_query_set().filter(*args, **kwargs)
    File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 498, in filter
      return self._filter_or_exclude(False, *args, **kwargs)
    File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 516, in _filter_or_exclude
      clone.query.add_q(Q(*args, **kwargs))
    File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1675, in add_q
      can_reuse=used_aliases)
    File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1569, in add_filter
      negate=negate, process_extras=process_extras)
    File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1737, in setup_joins
      "Choices are: %s" % (name, ", ".join(names)))
  FieldError: Cannot resolve keyword 'name' into field. Choices are:  monday,  tuesday, wednesday,  w_name
  </code></pre>
  
  <p>I need to query where i can join working and profile.</p>
  
  <p>support</p>
  
  <p><code>select working.*,profile.assign,profile.doj from working join profile where name=w_name ;</code></p>
  
  <p>I know django won't support joins,inner join  is also okay for me.</p>
  
  <p>Can any one help on this.........................?</p>