Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread Greg
I post some info to a view. When I do a 'assert False, request.POST' I see the following It should only have 8 keys (1 through 8). Instead I see the keys 'x' and 'y'? It's causing a problem when I try to loop through my POST data. Does anybody know why this is happening? Thanks --~--~---

Re: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread Greg
Jacob, Yep that was it. If I shouldn't assume anything from the browser. Then how would I loop through the contents of my data? Below is my view and template file / This code is in my template file {% for a in pad %} --- 1 2 3 4 5 {{ a.size }} -- ${{

Re: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread Nis Jørgensen
Greg skrev: > I post some info to a view. When I do a 'assert False, request.POST' > I see the following > > [u'2'], u'5': [u'2'], u'4': [u'3'], u'7': [u'---'], u'6': [u'2'], > u'y': [u'4'], u'8': [u'---']}> > > It should only have 8 keys (1 through 8). Instead I see the keys 'x' > and 'y'? It

Re: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread Jacob Kaplan-Moss
On 7/27/07, Greg <[EMAIL PROTECTED]> wrote: > It should only have 8 keys (1 through 8). Instead I see the keys 'x' > and 'y'? It's causing a problem when I try to loop through my POST > data. > > Does anybody know why this is happening? You're probably using an - those send along x/y coords of

Re: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread RajeshD
> {% for a in pad %} > > > I would suggest adding a prefix to that name: This way, when you are looping through your request.POST dictionary keys, you can skip keys that don't start with "pad-" that will prevent your loop from breaking if you get unexpected keys in the form post. --~--

Re: Displaying the contents of a Dict (Using POST)...showing 'x' and 'y' keys?

2007-07-27 Thread Nathan Ostgard
You can define a list of valid keys to look for: keys = ['one', 'two', 'three', 'four', 'five'] for key in keys: if not key in request.POST: continue .. do stuff .. Or you can delete the keys you don't want before looping: for key in ['x', 'y', 'submit']: del request.POST[key] for key