Friday, May 18, 2012

Re: Template: Foreign Key

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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate