question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you collectstatic in production?

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
browniebrokecommented, Sep 9, 2018

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.

0reactions
jklevecommented, Sep 9, 2018

@browniebroke That seems obvious now, thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found