That is what programming language? Note you can name what? 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
On Sat, 2007-07-28 at 19:44 -0700, Greg wrote:
> I tried to implement the above view. However, I'm having errors.
> Again i think it has to do with the u character in my dict. Here is
> my view:
[... snipped ...]
> This is the error I get:
>
> MultiValueDictKeyError at /rugs/cart/addpad/
>
I tried to implement the above view. However, I'm having errors.
Again i think it has to do with the u character in my dict. Here is
my view:
def addpad(request):
if request.method == 'POST':
pads = request.session.get('pad', [])
pad =
Right... because, unless I'm misunderstanding your code... you're
creating a select drop down for each of your RugPad entires with the
RugPad id. So you know that the request.POST is going to have entries
for each id...
But..I think it should be this:
opads = RugPad.objects.all()
for a in
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
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
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
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
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
Nathan,
Thanks for the iteritems() method. I implemented that into my code.
However, 'if values != 0:' never evaluates to False. Even though some
of the forms elements values are 0. For example when I do a assert
False, values on one of those elements I see:
AssertionError at
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
request.POST is a dictionary, not a list, so a for loop like yours is
iterating over the keys of the dict. to get the values, you can do:
for value in request.POST.itervalues():
to iterate over both keys and values:
for a, value in request.POST.iteritems():
On Jul 27, 2:54 pm, Greg <[EMAIL
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 =
13 matches
Mail list logo