What is the most flexlible and universal way to store media files with Django?

I am currently learning web development and I wonder what is the best and most flexible approach to storing media files? You never know how much will your website grow and because of that, I want to know how to handle big amounts of media files correctly using Django running on a Nginx server. I tried some googling, but media files handling in production is not that well documented, at least not as well as handling media files in development. Every suggestion will help me.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Really depends on how much searching and organizing you’ll need.

I personally prefer the idea of using a file-key in whatever DB I’m using that way I can experiment with different storage methods while the actual DB lookup keeps my static value. You’ll have to code something to load the actual media from the key, but you won’t have to worry about the two being tied together permanently.

Example: (I personally use mongo for my DB so everything is a JSON)

{ "_id":201,
  "title":"kitten fights lemon",

That way I can just lookup the media.type and media.Key against whatever storage I’m using.

I’m currently loading from Ext4 on debian, but am going to try BtrFS next to see if there is any difference.