class ThingForm(forms.Form): name = forms.CharField(max_length=30, required=True, label=_('Name of the thing')) photo = forms.Field(widget=forms.FileInput, required=False, label=_('Photo'), help_text=_('Upload an image (max %s kilobytes)' % settings.MAX_PHOTO_UPLOAD_SIZE))
def thing_add(request): if request.method == 'POST': new_data = request.POST.copy() new_data.update(request.FILES) form = ThingForm(new_data) if form.is_valid(): clean_data = form.clean_data t = Thing() t.name = clean_data['name'] if clean_data['photo']: photo = clean_data['photo'] t.save_photo_file(photo['filename'], photo['content']) please also read http://www.djangoproject.com/documentation/model-api/#filefield and http://batiste.dosimple.ch/blog/2007-05-13-1/ new forms have changed this binding and made things easy so you can also check http://www.djangoproject.com/documentation/newforms/#binding-uploaded-files-to-a-form --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---