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


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to