models.py - for Car Manufacturer and Models
class dbModel1(models.Model):
dbfield1 = models.CharField("Product Manufacturer", max_length=200,
unique=True)
class dbModel2(models.Model):
dbforeignkey = models.ForeignKey(dbModel1)
dbfield1 = models.CharField("Model", max_length=20)
dbfield2 = models.CharField("Info", max_length=200)
I want to create a complete list of manufacturers and models for the
menu sidebar like this (below) for using with Ajax menu, (this is the
first list so no id is passed).
Audi
model1
model2
BMW
model1
model2
Saab
model1
model2
I have tried a nested loop like this but can't find anyway of
filtering the second loop of models on manufacturer, so i just get a
list of all models in the second loop.
{% extends "base.html" %}
{% block title %}The current time{% endblock %}
{% block sidebar %}
<h2>Manufacturer</h2>
<ul>
{% for make in make_list %}
<li>
<a href="{{ make.get_absolute_url }}">{{ make.dbfield1 }}/</a>
<li>
{% for model in model_list %}
<h2>Model</h2>
<a href="{{ model.get_absolute_url }}">{{ model.dbfield1}}/</a>
{% endfor %}
</li>
</li>
{% endfor %}
</ul>
{% endblock %}
--
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.