Django: static file not found

前端 未结 1 1077
花落未央
花落未央 2020-12-18 06:15

Running Debian on Virtual Machine guest inside Windows host. Set Bridged for adapter-type. Installed Django on the guest and using build-in runserver and built-

相关标签:
1条回答
  • 2020-12-18 07:07

    I have managed to resolve my problem with the help from ChristophBluoss and DanielRoseman. There were 2 problems:

    1. I haven't ran python manage.py collectstatic.
    2. The config missed crucial settings - STATIC_ROOT and STATICFILES_DIRS.

    After adding those variables into settings.py file and successfully running collectstatic - everything worked fine.

    P.S. One should read Django documentation more carefully. It wasn't stated clear enough for me that collectstatic is the mandatory thing.

    EDIT: As DanielRoseman suggested collectstatic along with STATIC_ROOT is non-mandatory when DEBUG is set to True. I have tried to remove staticfiles and STATIC_ROOT - and it still works in my development environment. So STATICFILES_DIRS was the missing setting.

    0 讨论(0)
提交回复
热议问题