title: Django 1.8 - FieldError: Cannot resolve keyword into field
body: <p>I recently upgraded from Django 1.6 to Django 1.8. When I did, I found that I was no longer able to to do a lookup back through a foreign key relationship as described in: 
  <a href="https://docs.djangoproject.com/en/1.8/topics/db/queries/#lookups-that-span-relationships" rel="noreferrer">https://docs.djangoproject.com/en/1.8/topics/db/queries/#lookups-that-span-relationships</a>.</p>
  
  <p>The system is set up so that there are two projects which use the same database. (Not my idea, but not something I would like to change right now.) The project where the models were initially created and migrated works just fine after the upgrade, but the other one does not. The models file for each is identical.</p>
  
  <p>Models.py:</p>
  
  <pre><code>class Site(models.Model):
      name = models.CharField(max_length=255)
  
      class Meta:
          app_label = 'project1'
  
  class Page(models.Model):
      title = models.CharField(max_length=255)
      site = models.ForeignKey('Site')
  
      class Meta:
          app_label = 'project1'
  </code></pre>
  
  <p>Error traceback from the Django Shell:</p>
  
  <pre><code>&gt;&gt;&gt; x = models.Site.objects.filter(page__id=1000)
  Traceback (most recent call last):
    File "&lt;console&gt;", line 1, in &lt;module&gt;
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 679, in filter
      return self._filter_or_exclude(False, *args, **kwargs)
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/query.py", line 697, in _filter_or_exclude
      clone.query.add_q(Q(*args, **kwargs))
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1314, in add_q
      clause, require_inner = self._add_q(where_part, self.used_aliases)
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1342, in _add_q
      allow_joins=allow_joins, split_subq=split_subq,
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1154, in build_filter
      lookups, parts, reffed_expression = self.solve_lookup_type(arg)
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1035, in solve_lookup_type
      _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
    File "/home/user_name/project2/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1401, in names_to_path
      "Choices are: %s" % (name, ", ".join(available)))
  FieldError: Cannot resolve keyword 'page' into field. Choices are: name, id
  </code></pre>
  
  <p>In the first project, the same query works as expected:</p>
  
  <pre><code>&gt;&gt;&gt; x = models.Site.objects.filter(page__id=1000)
  [&lt;Site: http://stackoverflow.com&gt;]
  </code></pre>