[Fixed]-Heroku error using collect static with Django 1.10

1👍

STATIC FILE HANDLING IN DJANGO

in settings.py

import os
def root(folder):
    return os.path.join(os.path.abspath(os.path.dirname(__file__)), '..',folder)

create the static/media folder inside the project root

MEDIA_ROOT = root('media')
MEDIA_URL = '/media/'
STATIC_ROOT = root('staticstorage')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
    root('static'),
)

project root urls.py (project/project/urls.py)[django version 1.10 please reffer if you are not using this version]

from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

make run python manage.py collectstatic in your local machine , if it’s created staticstorage directory inside your project , it’s done …. go ahead with deploy……..

👤Cadmus

Leave a comment