I'm not sure if I'm following what your saying...but this is what I
think you want to do:

if request.method == 'POST':
               pads = request.session.get('pad', [])
               for pad in pads:
                    if request.POST[pad.id] <> '---': # the select
name should be the pad id based on your template code
                            # do something here ... because it wasn't
---


On Jul 27, 5:54 pm, Greg <[EMAIL PROTECTED]> wrote:
> I'm trying to loop through my POST data.  However I am having
> difficulties.  I think my 'for' statement might be wrong.  Below is my
> function and template code
>
> //////////////////////// View function
>
> def addpad(request):
>         if request.method == 'POST':
>                 pads = request.session.get('pad', [])
>                 i = 0
>                 b = 1
>                 for a in request.POST:
>                         if a != '---':
>                                 opad = RugPad.objects.get(id=b)
>                                 s = opad.size
>                                 p = opad.price
>                                 pads.append({'size': s, 'price': p})
>                                 request.session['pad'] = pads
>                         i = i + 1
>                         b = b + 1
>                 return render_to_response('addpad.html', {'spad':
> request.session['pad']})
>
> ///////////////// Template File
>
> {% for a in pad %}
> <tr>
>  <td>
>   <select name="{{ a.id }}">
>    <option value="---">---</option>
>    <option value="1">1</option>
>    <option value="2">2</option>
>    <option value="3">3</option>
>    <option value="4">4</option>
>    <option value="5">5</option>
>   </select> {{ a.size }} -- ${{ a.price }}
>  </td>
> </tr>
> {% endfor %}
>
> //////////////
>
> Notice how my 'for' statement is listed as ' for a in request.POST:
> '.  However, when i do a 'assert False, a' it always returns the value
> '1'.  I need to get the value of each select statement.  Such as (---,
> 1,2,3,4,5).
>
> Is that 'for' statement returning me the value of each select
> statement?
>
> Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to