Very beginner here.
My model has two classes, Suburb, the parent, and Street, the child:
class Suburb(models.Model):
suburb_name = models.CharField(max_length=72)
postcode = models.CharField(max_length=4)
def __unicode__(self):
return '%s %s' % (self.suburb_name, self.postcode)
class Street(models.Model):
street_name = models.CharField(max_length=72)
suburb = models.ForeignKey(Suburb)
def __unicode__(self):
return '%s, %s' % (self.street_name,
unicode(self.suburb))
In my view I populate the variable streets:
def search_street(request):
query = request.GET['query']
streets = Street.objects.filter(street_name__istartswith = query)
# Do a case-insensitive search on the starts-with name of the
street.
return render_to_response('wha/street_select.html', {'streets':
streets, 'query': query})
The page search_select.html contains:
<ul>
{% for street in streets %}
<li><a href=street.id>{{street.street_name}}
{{suburb.suburb_name}}</a></li>
{% endfor %}
</ul>
This displays only the street name, and not the suburb_name. I need
it to display as in the admin ie:
street_name suburb_name postcode
What change should I make or where can I see an example?
TIA
Mike
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---