1

I'm trying to install django debug toolbar to track ORM queries to the database. Got this erorr

WARNINGS:
?: (debug_toolbar.staticfiles.W001) debug_toolbar requires the STATICFILES_DIRS directories to exist.
        HINT: Running manage.py collectstatic may help uncover the issue. 

Decided to run python manage.py collectstatic and getting the error Here's the settings files.

settings.py



INSTALLED_APPS = [
    #...
    'django.contrib.staticfiles',
    #..
    'debug_toolbar',
]

MIDDLEWARE = [
    #...
    'debug_toolbar.middleware.DebugToolbarMiddleware', 
]

# ...

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': str(os.path.join(BASE_DIR, "db.sqlite3")),
    }
}


# ....

STATIC_URL='/static/'
STATICFILES_DIRS =[
    os.path.join(BASE_DIR,'static').replace("\\", "/"),
]

  • I tihnk don't need of replace method in `STATICFILES_DIRS ` Just use `os.path.join(BASE_DIR,'static')` – Pavan kumar May 04 '21 at 10:21
  • I didn't use it before. it didn't work anyway – Ivan Vorobyev May 04 '21 at 13:05
  • Is `DEBUG` equal to `False` in `settings.py`??? If yes and you are running django with `runserver`, then no need to do `collectstatic`, which is for deployment. You'd better create a `STATIC_ROOT = os.path.join(BASE_DIR, 'static/')` in your `settings.py` too. – AlirezaAsadi Apr 04 '22 at 01:35

1 Answers1

0

I found it. In your project's root directory, create a new directory called static_files. It should be alright now that that directory exists, and it seems to be needed because debug_toolbar queries that folder for files, for some reason without first checking whether the folder exists or not.