Static_root Setting In Django
I am learning Django and have built a sample Django app. It works fine on my computer, but I am having trouble deploying it to Heroku. My root directory has the following structur
Solution 1:
Here are the recommended settings for static root for a django -> heroku project
# Static files (CSS, JavaScript, Images)# https://docs.djangoproject.com/en/1.11/howto/static-files/ STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'# Extra places for collectstatic to find static files.STATICFILES_DIRS = [
os.path.join(PROJECT_ROOT, 'static'),
]
I would recommend just using this https://github.com/heroku/heroku-django-template as a starting point and import your apps into that project. Due to the fact (as of now) that Heroku recommends using the following packages
Gunicorn
WhiteNoise
dj-database-url
The git project will provide you with "Production-ready configuration for Static Files, Database Settings, Gunicorn, etc." In other words, it will give you the correct configuration to deploy Django to Heroku.
Post a Comment for "Static_root Setting In Django"