Ok, i'm having some trouble understanding on Django does joining and aliasing. I have four tables defined as such in my models: (i've removed un-pertinent columns)

```
class Field(models.Model):
    name = models.CharField(max_length=200, default='')

class Survey(models.Model):
    name = models.CharField(max_length=200, default='')

class Question(models.Model):
    text = models.CharField(max_length=200, default='')
    survey = models.ForeignKey(Survey)

class Answer(models.Model):
    question = models.ForeignKey(Question)
    field = models.ForeignKey(Field)

```

Now I can write a very simple and easy to understand sql query to get exactly what I want. which would look like this:

```
SELECT s.id, s.name, 
  q.id as q_id, q.text, 
  f.id as f_id, f.name as answer  
FROM "App_survey" s 
JOIN "App_question" q 
  ON q.survey_id = s.id
JOIN "App_answer" a 
  ON a.question_id = q.id 
JOIN "App_field" f 
  ON a.field_id = f.id;

```

But I can't for the life of me figure out how to do this using the orm. I can't even get two tables joined and select the data from both let alone deal with the aliasing. This is as far as I've gotten:

```
questions = Question.objects.prefetch_related('survey')
questions_dict = [{'form':x.name, 'id':x.id, 'question':x.text} for x in questions]

```

This gives me a 'Question' object has no attribute 'name' error.

Note: this is postgres and python and I am new to both.

Update: This is the final code which i used that works:

```
answers = Answer.objects.annotate(
    s_id=F('question__survey__id'),
    s_name=F('question__survey__name'),
    q_id=F('question__id'),
    text=F('question__text'),
    f_id=F('field__id'),
    answer=F('field__name')
)

surveys_dict = [{
    'id': x.s_id,
    'name':x.s_name,
    'q_id':x.q_id,
    'text':x.text,
    'f_id':x.f_id,
    'answer':x.answer
} for x in answers]

```

thanks to both answerers, they were enlightening.