As far as I know, there is no control of this type, however there is a very simple way to prevent folders from growing too much: separating files by the date of upload, through FileField.upload_to
:
class MeuModelo(models.Model):
meu_campo = models.FileField(upload_to='pasta/%Y/%m/%d')
As an example, if you create an instance of this template on 05/14/2015 with the file teste.txt
associated with the field meu_campo
, and your MEDIA_ROOT
for /var/www/uploads
it will be saved in the file:
/var/www/uploads/pasta/2015/05/14/teste.txt
You can vary how to organize folders using the same parameters of strftime
.
This does not guarantee, of course, that folders do not grow beyond a predefined size (will the user decided to register more than 800 files in the same day...), nor help anything if your application accepted upload files without them being associated with models. If this is a problem for you, just make this control by hand.
In your controller check to create a new folder or not before saving the file.
– LeoCBS