actually it worked even without the the set.all ,thanks for help

On Sat, May 19, 2012 at 4:51 AM, Kurtis Mullins <kurtis.mull...@gmail.com>wrote:

> Whoops -- that might need to be 'house.people_set.all'. Sorry.
>
>
> On Fri, May 18, 2012 at 10:50 PM, Kurtis Mullins <kurtis.mull...@gmail.com
> > wrote:
>
>> Try something along these lines (Note: I'm switching up your variable
>> names a bit to make it easier to read)
>>
>> {% for house in houses %}
>>     {{ house.name }}
>>     {% for person in house.people.all %}
>>         {{ person.name }}
>>     {% endfor %}
>> {% endfor %}
>>
>> I just wrote that code block pretty quickly but it should step you in the
>> right direction. Also, here's a related stackoverflow post:
>> http://stackoverflow.com/questions/1014591/traversing-foreign-key-related-tables-in-django-templates
>>
>> Good lucK!
>>
>>
>> On Fri, May 18, 2012 at 7:50 PM, Fady Kamal <fady.eldeso...@gmail.com>wrote:
>>
>>> it's not working with me
>>>
>>> On Tuesday, June 30, 2009 10:43:15 AM UTC+2, russelson wrote:
>>>>
>>>> Hi,
>>>>
>>>> I'm new to django
>>>>
>>>> I have two models
>>>>
>>>> #models.py
>>>>
>>>> class House(models.Model):
>>>>     name = models.CharField(blank=True, max_length=50)
>>>>
>>>> class People(models.Model):
>>>>     name = models.CharField(blank=True, max_length=50)
>>>>     house = models.ForegnKey(House)
>>>>
>>>> #views.py
>>>> def house_list(request):
>>>>         houses = House.objects.all()
>>>>         return render_to_response('test/**house_list.html',
>>>> {'object_list':
>>>> houses})
>>>>
>>>> #house_list.html
>>>> {% for object in object_list %}
>>>>     {{ object.name }}
>>>>     {{ object.people.name }}           #!?!?
>>>> {% endfor %}
>>>>
>>>> How do i retrieve the information in the People model?
>>>>
>>>> Please advice
>>>>
>>>> Thanks in advance
>>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msg/django-users/-/piLnSG9ycFEJ.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to