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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFHbX1K_%2B5hiqwzs--B7LEkvKFmfZ0pRemjUHfvUbzHQw35h0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to