Django - Static file not found

前端 未结 13 843
旧巷少年郎
旧巷少年郎 2020-11-30 20:46

I\'ve seen several posts for this issue but didn\'t found my solution.

I\'m trying to serve static files within my Django 1.3 development environment.

Here a

13条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-30 21:19

    I confused STATIC_ROOT and STATICFILES_DIRS

    Actually I was not really understanding the utility of STATIC_ROOT. I thought that it was the directory on which I have to put my common files. This directory is used for the production, this is the directory on which static files will be put (collected) by collectstatic.

    STATICFILES_DIRS is the one that I need.

    Since I'm in a development environment, the solution for me is to not use STATIC_ROOT (or to specify another path) and set my common files directory in STATICFILES_DIRS:

    #STATIC_ROOT = (os.path.join(SITE_ROOT, 'static_files/'))
    import os
    SITE_ROOT = os.path.dirname(os.path.realpath(__file__))
    STATICFILES_DIRS = (
      os.path.join(SITE_ROOT, 'static/'),
    )
    

    Also don't forget to from django.conf import settings

提交回复
热议问题