Custom saving path for FileField

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:

…and

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 :-)




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top