Carole,
So your saying that I should do:
opad = RugPad.objects.all()
for a in opad.id
if request[a] != 0
.....#add to session
On Jul 28, 8:43 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Greg... I'm curious as to why you're iterating over the entire
> request.POST when you could just use the id of each pad that you've
> previously passed to your template to retrieve it from the
> request.POST dict, as that is what you've named your select statements
> with?
>
> While iterating through all of the request.POST key/value pairs works,
> if you choose to later add any other inputs to your screen that aren't
> drop downs for your CarpetPads, you'll have to add special code for
> each of them so that your code won't attempt to add a RugPad for those
> key/value pairs. Just wanted to point that out, in case you might
> need to do that later.
>
> Carole
>
> On Jul 28, 9:15 am, Greg <[EMAIL PROTECTED]> wrote:
>
> > Nathan,
> > Thanks for your help...I got it working. This is what I used:
>
> > if values != list("0"):
>
> > Is that what you were recommending? Because I couldn't convert a list
> > (values) to a int. Since values was a list I decided to convert my
> > int to a list and that worked. Can you tell me what the u stands for
> > when i do a 'assert False, values': It returns a [u'0']. Why doesn't
> > it just return a ['0']? Also, it there anyway that I can convert the
> > 'values' variable to a int so that I can do a comparison without
> > converting the 0 to a list?
>
> > Thanks
>
> > On Jul 28, 2:57 am, Nathan Ostgard <[EMAIL PROTECTED]> wrote:
>
> > > To illustrate with the Python shell:
>
> > > >>> 0 == "0"
> > > False
> > > >>> 0 == int("0")
>
> > > True
>
> > > On Jul 27, 11:10 pm, Sean Perry <[EMAIL PROTECTED]> wrote:
>
> > > > On Jul 27, 2007, at 10:36 PM, Greg wrote:
>
> > > > > AssertionError at /rugs/cart/addpad/
> > > > > [u'0']
>
> > > > > Does that mean that the value is 0? below is my view function and
> > > > > template code:
>
> > > > That little 'u' in front of the '0' means unicode so the value is the
> > > > unicode string "0" not the number zero. Very different as far as
> > > > Python is concerned. You may be used to other scripting languages
> > > > that auto-convert. Python is not one of them.
>
> > > > try:
> > > > num = int(values)
> > > > if num == 0:
> > > > deal_with_zero()
> > > > else:
> > > > deal_with_number(num)
> > > > except ValueError:
> > > > # hmm, values is a string, not a number
> > > > deal_with_a_string(values)
>
> >
> > Hope that helps.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---