answer from stackoverflow:
http://stackoverflow.com/questions/499964/how-do-you-create-python-methodssignature-and-content-in-code/499982#499982
Python code behaves like this for functions defined in scope of
methods. Use this instead:
for image_name in image_fields:
print "image name is:
For some reason, _clean_photo is being given the last image name for
dataName, and that's why only the last picture is being validated.
The line of code that calls _clean_photo with the image name is:
setattr(new_form, 'clean_' + image_name, lambda self: self._clean_photo
(image_name))
This
Ok... maybe not so solved.
Now ony the last image submitted is validated. in the _clean_photo
(self, dataName) method, I print the data, and all the images except
for the last one contain None.
Any Ideas?
On Feb 1, 12:51 pm, DragonSlayre wrote:
> Solved my problem - data =
Solved my problem - data = self.cleaned_data[dataName] should have
been:
data = self.cleaned_data.get(dataName)
Silly me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group,
I've created a dynamic form to allow users to upload images, and I'm
trying to validate the form. - it displays fine, but when I validate
and return a response, I get either a Key Error at the line (data =
self.cleaned_data[dataName] ) in _clean_photo or I get a render error
in my template at {{
5 matches
Mail list logo