Custom saving path for FileField

Posted by in Uncategorized

Saving FileFields is pretty annoying anyway (all the manual stuff, saving chunks by hand…). The top bother is actually the limited way of creating paths: In MEDIA_ROOT, only with strftime arguments. While this does limit the number of files in a directory, it’s not as customisable as it should… So, here‘s the alternative:


Now, your files are going to be saved in a path containing the username, with a mangled local name (so the only way to see which file it is and what’s supposed to do is to look in the database). Cute.

A little experiment: If you find this post and ad below useful, please check the ad out :-)