James McGill
unread,May 16, 2008, 3:00:04 AM5/16/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi All,
I'm new to Django and I'm not sure how best to achieve the following:
Users may upload files - each uploaded file is tied to a user in the
database using a ForeignKey.
In order to prevent pain to the underlying O/S I don't want to put all
these files in to a single directory. I could separate the files by
upload time as mentioned in the Django documentation, but it would be
nicer to have all the files uploaded by a single user under a single
subdirectory.
Example:
Greg uploads "holiday.rtf", it is saved as /media/uploads/greg/
holiday.rtf
Sally uploads "family.rtf", it is saved as /media/uploads/sally/
family.rtf
My current model:
class FileModel(models.Model):
user = models.ForeignKey(User)
file = models.FileField(upload_to = 'uploads/'
I am saving the file using FileModel_Instance.save_file_file('path',
file_contents). Adding extra folders to the path (i.e. path = greg/
holiday.rtf) doesn't work - I assume this is a security restriction.
I am using the SVN version of Django. Any help would be appreciated.
Regards,
James