Re: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers
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 = self.cleaned_data[da

Re: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers
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 line

Re: Validating and rendering dynamic form

2009-01-31 Thread Louis Sayers
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: ",

Error saving a Model with a custom image field

2009-02-02 Thread Louis Sayers
I have an Image model: class Image(models.Model): photo = ImageWithThumbsField( upload_to=image_upload_location, sizes=((thumb_widths,thumb_heights),)) The ImageWithThumbsField is something I got from http://code.google.com/p/django-thumbs/ It seems to work fine when

Re: Error saving a Model with a custom image field

2009-02-02 Thread Louis Sayers
I'm running the official release of django 1.02 Do you think there'd be any problems with this version? I've only been using django for the last 2 months, so I'm fairly new to it, and haven't investigated different revisions etc On Feb 3, 12:58 pm, Andrew Ingram wr

Re: Error saving a Model with a custom image field

2009-02-02 Thread Louis Sayers
I think it must be something that I'm not doing. It all works when I'm using a ModelForm, so there must be a difference between what I'm doing manually, and what the ModelForm does for me. The culprit must be my code: new_image = ImageWithThumbsField(images_to_save[image], up

removing cached form fields

2009-02-09 Thread Louis Sayers
I've got a django Form which contains a dictionary of strings. I've given the form a submit button and a preview button. When the preview button is pressed after entering some information, a POST is sent, and the strings in the dictionary are automagically recovered (I assume that it's done using

Re: removing cached form fields

2009-02-09 Thread Louis Sayers
Ok, I'm not doing any django for the next couple of days, so will post when I have a watered down example (unless of course doing this solves the problem :)) On Feb 10, 4:36 pm, Malcolm Tredinnick wrote: > On Mon, 2009-02-09 at 17:17 -0800, Louis Sayers wrote: > > I've got

What is the best way to keep state between posts?

2009-02-12 Thread Louis Sayers
Howdy, I've created a form that allows a user to post images to the server. Once the images are posted, I am saving them to disc, and if there are any errors, I return the form with the errors in them, and thumbnails of the successfully uploaded pictures. If they are unsuccessful when they post

Re: bookmarks app with images

2009-02-12 Thread Louis Sayers
Firstly, make sure that you have the enctype="multipart/form-data" attribute on your form in your template. You can create an object of your form by writing: formObject = BookmarkSaveForm(request.POST, request.FILES) test if it's valid: if formObject.is_valid(): Looking at your Photo model, yo