On 26.02.2015 02:30, 163 email wrote:
> yes , what i mean is "media files".
> there are so many file,may be several thousands ,to be uploaded
> from client to server.
> if all files in one dir , it'll be slow.
> but i don't find any way put files in different dirs just using django.
> now i write a function to put files in different dirs ,but it complex.
> is there any easy way ?
> Thanks !
> ------------------------------------------------------------------------
> 163 email
There is an easy way for accomplishing what you want mentioned in
djangos docs:
»For example, say your MEDIA_ROOT is set to '/home/media', and upload_to
is set to 'photos/%Y/%m/%d'. The '%Y/%m/%d' part of upload_to is
strftime() formatting; '%Y' is the four-digit year, '%m' is the
two-digit month and '%d' is the two-digit day. If you upload a file on
Jan. 15, 2007, it will be saved in the directory
/home/media/photos/2007/01/15.«
https://docs.djangoproject.com/en/1.7/ref/models/fields/#django.db.models.FileField.storage