The "name" attribute should be on the select tag. E.g:

<select name="customer_id">
  <option value="foo">Foo</option>
</select>

_Nik
On 6/20/2014 10:33 AM, G Z wrote:
> I'm trying to post
> customer_id
> while generating a combo box with a loop from a database query.
> I have the combo box generating and such, but the posted data does not
> return the customer id. It returns something weird.
>
>     <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 }}
>
>
>
> this is what it returns
> <QueryDict: {u'csrfmiddlewaretoken':
> [u'CpzKrwmZsmfiiNHngNWDFSNxqUoBykYO']}>
>
>
>     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+unsubscr...@googlegroups.com
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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/e75fd019-a74e-415f-b681-8617a781cf38%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e75fd019-a74e-415f-b681-8617a781cf38%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/53A47679.4050309%40consbio.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to