Re: how to put files in different dirs

2015-02-26 Thread Rodrigo Zayit
Yeah! Or you can write your own method to upload_to. It is easy too.

I've made a simple example:

https://gist.github.com/rodrigo-zayit/604da297d9c30e7d

This example save the pictures in:

media/images/products/1/product-slug/randomstring.ext

Where "1" is the id of the product's category.


Best regards,
Rodrigo Zayit



On Thursday, 26 February 2015 06:18:29 UTC-3, Michael Pöhn wrote:
>
> 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
>  
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0d872736-383a-4975-bb46-ed3fb888b946%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to put files in different dirs

2015-02-26 Thread Michael Pöhn
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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54EEE445.9030409%40fsfe.org.
For more options, visit https://groups.google.com/d/optout.


Re: Re: how to put files in different dirs

2015-02-25 Thread 163 email
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

From: Rodrigo Zayit
Date: 2015-02-25 23:36
To: django-users
CC: paiis314
Subject: Re: how to put files in different dirs
Hi!


I didn't understand your question. You don't need to put all your files in the 
same dir... you can create folders like "images", "images/products", "css", 
"js", etc
Or are you asking about "media files"? I mean, files that will be uploaded 
through admin area...?


Best regards,
Rodrigo Zayit

On Wednesday, 4 February 2015 11:50:11 UTC-2, 老张 wrote:
hi . Guys
i'm designing a django web site,which produce many files.
if all these files are in ONE directory。i'm afraid that performance is a 
problem.
even i can put many entries in  stattic-dirs in setting.py.but it seems only 
one entry in stattic-dirs be used
Can anyone tell me how  i  can put files in different dirs , or in different 
dirs with same parent dir ?
Thanks !







-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12150c6c-e90e-414c-be8b-e77d4d220308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/201502260930373900639%40163.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to put files in different dirs

2015-02-25 Thread Rodrigo Zayit
Hi!

I didn't understand your question. You don't need to put all your files in 
the same dir... you can create folders like "images", "images/products", 
"css", "js", etc
Or are you asking about "media files"? I mean, files that will be uploaded 
through admin area...?

Best regards,
Rodrigo Zayit

On Wednesday, 4 February 2015 11:50:11 UTC-2, 老张 wrote:
>
> hi . Guys
> i'm designing a django web site,which produce many files.
> if all these files are in ONE directory。i'm afraid that performance is a 
> problem.
> even i can put many entries in  stattic-dirs in setting.py.but it seems 
> only one entry in stattic-dirs be used
> Can anyone tell me how  i  can put files in different dirs , or in 
> different dirs with same parent dir ?
> Thanks !
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12150c6c-e90e-414c-be8b-e77d4d220308%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.