How to setup django media files folder with DO Apps and static sites components?

Posted December 18, 2020 1.8k views
PythonDjangoPython FrameworksDevelopmentDigitalOcean App Platform

I am following this tutorial to set up my Django app on the DO App platform.

Everything is working as expected other than media files. I tried different configurations and settings at my file but I am unsuccessful.

Do I need to add a media static site service for this? Or can I use the same static site? Any help will be appreciated.

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.

Submit an Answer
2 answers

Did you find a way ??

Has anyone figured out how to make MEDIA files work, similar to STATIC files other than using DO spaces? I tried adding another static component and configured the Route and the output to point to the media folder, in vain… I still get a 404.

Hopefully there is a part 2 of the tutorial addressing MEDIA files.


  • I’m looking forward to the second part of the tutorial.

  • For what it’s worth, I have just managed to figure my MEDIA stuff out.

    DO is essentially using Heroku engine for the App Platform, so I seem to have found the solution on Heroku forum :)

    The key for me to start handling media files properly was:
    1) make sure you have all the necessary folders in place (ex. locations where uploaded media is gonna be stored)
    2) add MEDIA_ROOT to urlconf. In other words: in the for the root Django component, add:

    from django.conf import settings
    from django.conf.urls.static import static

    and later, after your list of proper paths, add the media url:

    urlpatterns = [your url stuff] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT).

    It worked on my… container? :)