On Mon, May 12, 2014 at 10:47 PM, G Z <
zuk...@gmail.com> wrote:
> I'm just trying to associate each vm tied to the customers id and display
> the vms under the customer that are associated with his id.
>
Normally, you would have some sort of relationship between those
models, and the template code would look something like this:
{% for customer in customers %}
{% for vms in customer.vms_set.all %}
<div>{{
vms.id }} - {{ vms.NAME }} - {{ d.VMNAME }}</div>
<!-- etc -->
{% endfor %}
{% endfor %}
Please note, even if you are using a legacy database, there is no need
for the model's fields to have the same name as the table column. All
caps normally denotes a constant, these are not constants, and
"VMNAME" is less pleasant to look at than "virtual_machine_name" or
even "vm_name".
One other thing, your view, you should be actually calling the
function "all()", not passing the function object "all":
def index(request):
customers = Customer.objects.all()
ctx = { 'customers':customers }
return render_to_response('index.html', ctx)
Note the brackets, and you no longer need to pass in 'vms' either, as
it should come from the relation.
If this doesn't work, please show your models.
Cheers
Tom