【问题标题】:Django Found another file with destination pathDjango找到另一个带有目标路径的文件
【发布时间】:2019-10-14 14:24:01
【问题描述】:

我正在尝试在 GCP 上部署应用程序,但是当我运行以下命令时:

python manage.py collectstatic

返回:

找到另一个具有目标路径的文件 'admin\css\autocomplete.css'。它将被忽略,因为只有第一个 遇到的文件被收集。如果这不是您想要的,请确保 每个静态文件都有唯一的路径。

找到另一个目标路径为“admin\css\base.css”的文件。它 将被忽略,因为只收集第一个遇到的文件。如果 这不是您想要的,请确保每个静态文件都有唯一的 路径。

还有很多类似的。

这是我的 Settings.py

STATIC_URL = 'https://storage.googleapis.com/yantra-packs/static/'
# STATIC_URL = '/static/'

# STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]


PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/'), ]

我在哪里为静态文件提供了两条路径?

【问题讨论】:

    标签: python django


    【解决方案1】:

    findstatic 命令将有助于调试。


    STATICFILES_FINDERS的默认值为:

    [
        'django.contrib.staticfiles.finders.FileSystemFinder',     # finds files stored in the `STATICFILES_DIRS` setting.
        'django.contrib.staticfiles.finders.AppDirectoriesFinder', # finds files stored in the 'static' subdirectory of each app.
    ]
    

    因此,即使你只有:

    STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static/'), ]
    

    AppDirectoriesFinder 将查找存储在each appstatic 子目录中的文件。


    另外,您可能想查看描述collectstatic 命令的 Django 官方文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-21
      • 1970-01-01
      • 2015-12-04
      • 2019-09-16
      • 1970-01-01
      • 2019-10-26
      • 1970-01-01
      • 2013-05-29
      相关资源
      最近更新 更多