Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django on Heroku - Broken Admin Static Files

I have a Django app running on Heroku/Cedar, configured as per the instructions at https://devcenter.heroku.com/articles/django

Using gunicorn as per Heroku's instructions fails to include the static files required for Django's admin to function. I can change the Procfile to "manage.py run_gunicorn" for local development, but that doesn't fly on Heroku.

I've searched all over for a fix - is there some way to include the admin static files without throwing them on S3 with my other static files?

like image 304
caldercho Avatar asked Apr 25 '12 03:04

caldercho


People also ask

Does Heroku support static files?

You should store them externally on a service like S3 - while Heroku can serve static files, it's not designed to.

What is WhiteNoise in Django?

Project description WhiteNoise works with any WSGI-compatible app but has some special auto-configuration features for Django. WhiteNoise takes care of best-practices for you, for instance: Serving compressed content (gzip and Brotli formats, handling Accept-Encoding and Vary headers correctly)


1 Answers

If you use runserver and configure your app with DEBUG=True, then it will serve the admin files just like on your development machine. However, this is definitely not the recommended way to do it, and I would suggest that you put them on S3.

Using the django-storages app it's very easy to configure collectstatic to automatically push all the admin files to S3. You can find directions here

like image 78
cberner Avatar answered Oct 12 '22 22:10

cberner