How do you collectstatic in production?
See original GitHub issueI’ve been searching around not finding much on this.Hope it’s fine to ask this here as I originally started the project from this template.
My first thought to collect the static files in a production environment was to go onto the production server and run ./manage.py collectstatic
. The issue with this was that the developer pip packages weren’t installed so running manage.py threw an import error. I’m assuming this is the incorrect way to do it. My next thought was that collectstatic
should be done in a similar fashion to the Amazon S3 collectstatic class but I can’t seem to find an already built solution to send your static files to your own server and save them in some directory. Is there a solution to this already?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
The staticfiles app - Django documentation
If you're confused, the findstatic command can help show you which files are found.
Read more >How do you collectstatic in production? · Issue #1786 - GitHub
The collectstatic command is working with your static files config and copies files to whatever static file storage you have configured.
Read more >serving static files on Django production tutorial - Stack Overflow
Next you want to collect the static files in your Django into one directory and point apache at that directory. You can do...
Read more >Working with Static and Media Files in Django | TestDriven.io
This article looks at how to work with static and media files in a Django project, locally and in production.
Read more >Django and Static Assets | Heroku Dev Center
When a Django application is deployed to Heroku, $ python manage.py collectstatic --noinput is run automatically during the build. A build will ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is working as expected, the manage script defaults to local settings, and on production, you should set an environment variable to use the production settings:
DJANGO_SETTINGS_MODULE='config.settings.production'
Here are links:
If you deploy the project on another type of production machine, not using Docker, I would recommend checking with your hosting provider how to set environment variables.
@browniebroke That seems obvious now, thank you.