<form method='post' action='' id='customers'>
{% csrf_token %}
<select>
{% for item in customer %}
<option value={{ item.customer_id }} name='customer_id'>{{ item.customer_name }}</option>
{% endfor %}
<input type = 'submit' value='Edit'>
</select>
{{ post }}
def portal(request):
customers = Customer.objects.all()
if request.method == 'POST':
vm_groups = Vm_group.objects.all()
vms = Vm.objects.all()
selected_customer = request.POST.copy()
#selected_customer_id = selected_customer['customer_id']
post = selected_customer
context = Context({'customer': customers, 'vm_groups':vm_groups, 'vms':vms, 'post':post,
})
return render(request, 'portal.html', context)
else:
context = Context({'customer': customers,})
return render(request, 'portal.html', context)
--
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...@googlegroups.com.
To post to this group, send email to django...@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/e75fd019-a74e-415f-b681-8617a781cf38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
{% if user.is_authenticated %}
<h1>Enki-Corp says... hello {{ user.username }}!</h1>
{% else %}
<h1>Enki-Corp says... hello world!</h1>
{% endif %}
{% if user.is_authenticated %}
<form method='post' action='' id='customers'>
{% csrf_token %}
<select name='customer_id'>
{% for item in customer %}
<option value={{ item.customer_id }} >{{ item.customer_name }}</option>
{% endfor %}
<input type = 'submit' value='Edit'>
</select>
<table>
<tr>
<th>ID</th>
<th>NAME</th>
</tr>
<br>
{% for item in customer %}
{{post}} - {{item.customer_id}} <br> //where I print them out to check if they match when infact there is a matching number it does nothing. but all my if statements below work.
{% if post == item.customer_id %}
test
<tr>
<td valign='top'>{{ item.customer_id }} <a href="{{ item.customer_id }}">{{ item.customer_name }}</a>
<li>Customer Inactive: {{item.inactive}}</li>
</td>
<td>
{% for group in vm_groups %}
{% if item.customer_id == group.customer_id %}
{% for vm in vms %}
{% if group.vm_group_id == vm.vm_group_id %}
<ul>
<li>VM Name: {{vm.vm_name}}</li>
<ul>
<li>VM ID: {{vm.vm_id}}</li>
<li>VM Display Name: {{vm.vm_display_name}}</li>
<li>VM Group: {{group.vm_group_name}}</li>
<li>Vm Mor: {{vm.vm_mor}} </li>
<li>Vm Datacenter: {{vm.datacenter_id}} </li>
<li>VCD Managed: {{vm.vcd_managed}} </li>
</ul>
</ul>
{%endif%}
{%endfor%}
{%endif%}
{% endfor %}
</td>
</tr>
<tr>
<td colspan='2' align='center'> </td>
{%endif%}
{% endfor %}
</table>
</form>
<a href="/logout/">Logout</a><br />
{% else %}
You are not authenticated.
<a href="/login/">Login</a><br />
{% endif %}