Sorry guys. Brain Freeze. I'm not trying to upload a form, i'm trying
to upload a FILE ... oops.
On Feb 23, 12:31 pm, dbee <[EMAIL PROTECTED]> wrote:
> So I'm trying to upload a form with oldforms, which in itself seems
> tricky enough. But I've also got the added 'benefit' of using multiple
> models ...
>
> MODEL:
>
> # Store the people who need reminding of
> things
> class TeleInt (models.Model):
> # Which client does this correspond
> to ?
> business_name = models.CharField( maxlength=100 )
>
> # Store files attached to
> TeleInt ...
> class Files_Attach (models.Model):
>
> # Any files associated with this
> account
> teleint = models.ForeignKey('TeleInt', blank=True, null=True,
> related_name="tele" )
> filename = models.FileField(upload_to="/site_media/files/")
>
> class Admin:
> pass
>
> def __str__(self):
> return self.filename
>
> VIEW:
>
> # Are we adding a file to the
> profile ?
> if new_data.get('files_attach','') != '' :
>
> # This contains only file
> data
> new_file_data = request.POST.copy()
>
> # This has to be added for a file
> upload
> new_file_data.update(request.FILES)
>
> # Also grab an add manipulator for the file
> upload
> file_manipulator = Files_Attach.AddManipulator()
>
> # Save the file
> manipulator
> new_file_data['filename'] = new_data['files_attach']
> new_file_data['teleint'] = teleint.id
>
> file_manipulator.save(new_file_data)
>
> TEMPLATE:
>
> <tr>
> <td><b>Add Files :</b></td>
> <td>
> <input type="file" name="files_attach" >
> </td>
> </tr>
>
> * I've created a dir /site_media/files and I've given apache rwx
> access ...
>
> * I've added multi-part to the actual form itself
>
> The file name gets added to the db no problem. But the actual file
> doesn't appear on my server ...
>
> I never would have imagined that uploading a file would be so
> complex.
>
> Please don't tell me to upgrade to newforms....
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---