【问题标题】:Collect Static creating a clone of my static files folder Django收集静态创建我的静态文件文件夹 Django 的克隆
【发布时间】:2020-07-12 19:51:04
【问题描述】:

我需要刷新我的静态文件文件夹中的 js 文件,但是每当我运行 python manage.py collectstatic 时,我的静态文件文件夹的克隆会在项目的不同部分创建,并且 js 文件仍然没有更新。我尝试将 settings.py 文件中的 STATIC_ROOT 变量更改为我的静态文件夹的实际位置,但它似乎没有刷新,因为控制台中的 collectstatic 警告消息说它将被保存在一个完全不同的位置。

我的项目结构是

resume_V6-test
    -resume
        -home
            -static (actual location)
        
        -resume
            -settings.py
        -store
        -staticfiles (clone of the static folder)
        -users

我的 settings.py 是

# Commented out the location it was before I tried fixing the error

#STATICFILES_DIRS = [
    #os.path.join(BASE_DIR, "static"),
    #'/resume_V6-test/resume/home/static',
#]


#STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_ROOT = os.path.join(BASE_DIR, 'home/static')
STATIC_URL = '/static/'

错误信息是

 python manage.py collectstatic

You have requested to collect static files at the destination
location as specified in your settings:

    C:\resume_V6-test\resume\staticfiles

This will overwrite existing files!
Are you sure you want to do this?

谢谢

【问题讨论】:

    标签: python django


    【解决方案1】:

    STATIC_ROOT 是静态文件的输出目的地。例如。这是 collectstatic 将所有静态文件收集到的地方(在此处阅读 https://docs.djangoproject.com/en/3.0/howto/static-files/

    默认是从每个应用的/static目录中收集所有应用的所有静态文件。

    如果你想从额外的位置收集,你可以使用 STATICFILES_DIRS 设置。 (https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-STATICFILES_DIRS)

    【讨论】:

      猜你喜欢
      • 2021-12-05
      • 2020-06-14
      • 2014-01-25
      • 2016-02-02
      • 2012-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-09
      相关资源
      最近更新 更多