I ran manage.py collectstatic
on my webapp and now I have a new static folder with only Django admin files (so far I've been using just CDNs for my project CSS and JS files). Should I track these admin static files on my git repo? What's the best practise?
Asked
Active
Viewed 8,397 times
28

Giacomo Sarrocco
- 421
- 1
- 7
- 16
1 Answers
36
While you can absolutely check these files in, I typically recommend not checking in the collected static files into git (we use .gitignore to ignore them). Instead, we call collectstatic
during our build/deploy steps so that if anyone ever adds new static files, they are collected and copied to the proper output directory for serving by nginx or sent up to s3. If you want to check them into git, I would recommend having collectstatic as a precommit hook so that no one accidentally forgets to run it when adding a new static file.

2ps
- 15,099
- 2
- 27
- 47
-
how are you solving the problem with the static folder? mkdir in your build process or added to git repo with a workaround like this? https://stackoverflow.com/questions/4250063/how-to-gitignore-all-files-folder-in-a-folder-but-not-the-folder-itself – zypro Jun 21 '17 at 13:17
-
@zypro: not following your question? The static folder where static folders across apps/projects are collected and stored to, or the static folders (plural) that django looks for when collecting static files in preparation for production? – 2ps Jun 22 '17 at 15:20