Malcolm, I wasn't very clear in my question. Sorry about that.
It took a bit of trial and error but I found a hack that works the way I want it to. I use the model and form_for_model/form_for_instance for all fields except the file uploads. For the file uploads I use FileInput(). That was what I meant by '... I could leave the FileFields out of the model and use a form class for those fields instead.' I you have any suggestions on how to secure/improve/validate this please let me know. Thanks, Vincent class files(forms.Form): file1 = forms.Field(widget = forms.FileInput()) file2 = forms.Field(widget = forms.FileInput()) def save(file,key,user,ext): if ext in ['pdf','doc']: f = open('%s%s_%s.%s' % ('/home/myhomedir/',key,user,ext,),'wb') f.write(file) f.close() @login_required def submit(request): try: # show previous input if available inst = Application.objects.get(user=request.user) ApplicationForm = form_for_instance(inst) except: # else create an empty form ApplicationForm = form_for_model(Application) if request.POST: form1 = ApplicationForm(request.POST) if form1.is_valid(): form1.cleaned_data entry = form1.save(commit=False) entry.user = request.user entry.save() # save files attached to the form pfile = request.POST.copy() pfile.update(request.FILES) form2 = files(pfile) for i in request.FILES.keys(): ext = request.FILES[i]['filename'][-3:] file = request.FILES[i]['content'] save(file,i,request.user,ext) # confirm data is submitted return render_to_response('submit/thankyou.html') else: form1 = ApplicationForm() form2 = files() return render_to_response('submit/submit.html',{'form1':form1,'form2':form2,}) #### TEMPLATE ##### <h2><strong>Form</strong></h2> <form method="post" enctype="multipart/form-data"> <table> {{ form1.as_table }} {{ form2.as_table }} </table> <input type="submit" value="submit"/> </form> On 6/12/07 8:12 PM, "Malcolm Tredinnick" <[EMAIL PROTECTED]> wrote: > > On Tue, 2007-06-12 at 20:03 -0500, Vincent Nijs wrote: >> Thanks for the reply Malcolm. >> >> That is too bad. I noticed that the FileFields do have a browse button in >> the admin form btw. Do they not use form_for_model? >> >> As an alternative, is there a way to use FileField 's separately from the >> the form_for_model fields? I am thinking I could leave the FileFields out of >> the model and use a form class for those fields instead. Not sure how to get >> this done however. Any suggestions/examples? > > Your questions don't really make sense. There is no FileField in > newforms yet. The current admin interface does not use newforms, so it > isn't pertinent to the issue. > > Do not get model fields and form fields confused, since they are > entirely different objects serving different purposes. You certainly > cannot chop and change them. > > Regards, > Malcolm > > > > > -- Vincent R. Nijs Assistant Professor of Marketing Kellogg School of Management, Northwestern University 2001 Sheridan Road, Evanston, IL 60208-2001 Phone: +1-847-491-4574 Fax: +1-847-491-2498 E-mail: [EMAIL PROTECTED] Skype: vincentnijs --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---