[Answered ]-Django Debug Toolbar Causes Loss of Static Files

1👍

I am not sure what is happening, but here are a few points to check:

  1. When DEBUG_TOOLBAR is false, is django.contrib.staticfiles in INSTALLED_APPS? If it was added, this line

    INSTALLED_APPS += (‘django.contrib.staticfiles’,’debug_toolbar’,)

    can cause a duplicate app name. It should not cause any problem, but you can try removing the duplicate.

  2. Are you sure DEBUG is set to True? When DEBUG is False, the development server refuse to serve static files (CONNECTION RESET?), and if you add –insecure option, it serves static files. This is like what you described.

  3. Have you overrided the url mapping of “/static/” in urls.py?

  4. Are you starting this server in a virtual machine? If so, you can try starting your server with:

    python manage.py runserver 0.0.0.0:8000

    and add your virtual machine’s IP addresses to INTERNAL_IP.

1👍

I think this happens when you are using a virtual environment. The problem is that Django packages are installed there and the project can’t access the files. You can fix that by running (based on your python version) python3 manage.py collectstatic in the console. This is how I fixed this problem on my end. Hope it helps your case

👤Xulw

Leave a comment