Maksim Kevin
Maksim Kevin

Reputation: 71

do we have to deploy staticfiles folder to heroku?

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?

Upvotes: 4

Views: 1180

Answers (2)

Emmanuel Osimosu
Emmanuel Osimosu

Reputation: 6004

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'),
)

Upvotes: 2

doniyor
doniyor

Reputation: 37876

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'),
)

Upvotes: 2

Related Questions