using rstrip on form.cleaned_data in Django

In my, i have a snippit of code like this:

def clean_post_data(form):
    for i in form.cleaned_data:
    	form.cleaned_data[i] = form.cleaned_data[i].rstrip()

def add_product(request):   
    form = ProductForm(request.POST, request.FILES or None)
    image = Image.objects.all()
    action = "Add"

    if request.POST:
    	if form.is_valid():
    		action = "Added new product"
    		return render_to_response('cms/admin/action.html', {'action' : action},context_instance=RequestContext(request))
    		action = "There was an error. Please go back and try again"
    		return render_to_response('cms/admin/action.html', {'action' : action}, context_instance=RequestContext(request))

    return render_to_response('cms/admin/editproduct.html', {'form' : form, 'action' : action, 'image' : image}, context_instance=RequestContext(request))

But when i run that, i get the following error 'list' object has no attribute 'rstrip'. What am i doing wrong.

I originally had the for i in form.cleaned_data: loop directly in the view (not in another function) and it worked fine, but now when i try it i get the same error as above.


The clean_post_data shouldn't be a stand-alone function.

It should be a method in the form, named clean. See Form and Field Validation.

Need Your Help

Error reading from webservices xml file

php xml

I'm trying to get a product list for a client from a webservices xml file over to an SQL databse using a little php script, but I can't seem to get it to work.

Checkout SVN repository from a network

svn windows-xp tortoisesvn windows-server-2003

I asked a similar question before How to update TortoiseSVN over the network?. At that time I was using a VM copy of the server, and the solution I listed worked. This time I am using the actual se...