title: Django handling Foreign Keys of tables in VIEWS in postgres; QuerySet always empty
body: <p>Is Django or maybe POSTGRESQL losing information about primary keys and foreign keys when you create a view which relates to a view which relates to a table, which has primary and foreign keys?</p>
  
  <p>I have a View-A (all 3 fields are Foreign Keys) and that view gets 2 fields from a View-B. The View-B gets its fields from a table-C. table-C has primary key and foreign key.</p>
  
  <p>So when i access View-A with my django model, how do i treat those fields? I know they are foreign keys, but any kind of filter results in a empty Queryset.
  if i use something like</p>
  
  <pre><code>myview = viewA.objects.using(db).all()  # getting all the data
  myview2= viewA.objects.using(db).all()[:5] # getting 5 objects
  </code></pre>
  
  <p>.</p>
  
  <pre><code>class viewA(models.Model):
  class Meta:
      db_table = "viewA"
  
  x = models.ForeignKey(x, primary_key=True)
  y = models.ForeignKey(y)
  z = models.ForeignKey(z)
  </code></pre>
  
  <p>The problem is that i can not filter!</p>
  
  <pre><code>response=viewA.objects.using(db).filter(y_id=1)  ERROR:= FieldError
  </code></pre>
  
  <p>Behind all those FK, there are integer/bigint fields.</p>
  
  <p>Edit:
  Since this are INNER JOINS i would like to access not only the fields from ViewA, but also from ViewB. x,y,z are from type ViewB. Maybe use <strong>select_related()</strong>?</p>
  
  <p>So any clues if Django or postgres lose information about keys in views which relate to other views?</p>