5

Should I commit and push my Django's project static files into my git repo? I know there is collectstatic command but it's just for prod deployment right?

I work on the same project from 2 different computers and then, I have static files in one that I don't have on the other.

Am I supposed to collectstatic from one to the other? But I don't understand this command neither how to use it nor what it does.

Thank you for helping.

Best regards.

Beno
  • 518
  • 1
  • 7
  • 22
  • Does this answer your question? [Should I add Django admin static files to my git repo?](https://stackoverflow.com/questions/41558258/should-i-add-django-admin-static-files-to-my-git-repo) – Benyamin Jafari Apr 25 '22 at 07:11

1 Answers1

7

Yes, normally we commit static files.

The command collectstatic just copies the static files from the individual app folders into one general folder (normally used only in PROD server).

But the static files should already be present (and committed) in the individual app folders, so that each development PC and also the PROD server have the same static files present.

Ralf
  • 16,086
  • 4
  • 44
  • 68
  • 1
    Ok thank you!! But even the fontawesome or bootstrap statics too? Thanks for helping, that makes sense to me now! – Beno Sep 22 '20 at 06:44
  • 1
    @Beno Yes, commit libs like fontawesome and bootstrap too. The only reason you would not commit them is if you are linking an externaly hosted copy of those libs (for example on Cloudflare or another CDN, see example in [bootstrap docs](https://getbootstrap.com/docs/4.0/getting-started/introduction/#js)). – Ralf Sep 22 '20 at 10:30
  • But here's another [claim](https://stackoverflow.com/a/41558803/3702377)! – Benyamin Jafari Apr 25 '22 at 07:10