Search code examples
djangodjango-templatesdjango-staticfilesdjango-inlinecss

django-inlinecss returns error You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path


I am trying to load a page as PDF. actually it loaded successfully - without any style or even the images. So I installed django-inlinecss and added it in installed_apps in settings.py and loaded it in template and called it as I was told. but it returns an error

You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

and points at:

1   {% load inlinecss %}
2   {% load static %}
3   {% inlinecss "css/style.css" %}    <---

I don't have any idea how to fix it. Hope someone could help me in this


Solution

  • actually it worked when I set directory for STATIC_ROOT. but there is one thing to be noticed that you have to set another directory for that. Which means STATIC_URL and others like STATIC_FILE_ROOT, STATICFILES_DIRS shouldn't be the same as STATIC_ROOT

    eg:

    MEDIA_URL = '/media/'
    MEDIA_ROOT = os.path.join(BASE_DIR, "media")
    STATIC_URL = '/static/'
    STATIC_FILE_ROOT = os.path.join(BASE_DIR, "static")
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, "static"),
    )
    STATIC_ROOT = os.path.join(BASE_DIR, "static/assets")
    

    sorry if that's not what you are looking for.