When I follow some tutorial on the web, there is staticfiles folder included in .gitignore file. Although when I included it in .gitignore file it is deployed to heroku server. I can see that folder in my main directory. Then why is it included in .gitignore file?
you dont commit your static folder to version control, you normally make another site-static folder for your css, js and img. it is simply because there are many other static files coming from e.g. django admin which lands into static folder if you do collectstatic. after collectstatic you will see many other static files of django apps / another installed apps which makes it hard to manage your own static files. thats why you need to ignore static folder and work locally in your site-static folder
I can see that folder in my main directory: that folder came from collectstatic command which collects all static files into static folder.
dont forget to make:
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, 'site-static'),
)
Heroku looks for all folders named static in your project and copies all asset files from these folders to staticfiles on heroku. You don't need to manually create and push the staticfiles folder to heroku. It is created automatically.
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With