【问题标题】:Django warnings (Make sure every static file has a unique path)Django 警告(确保每个静态文件都有唯一的路径)
【发布时间】:2023-02-23 04:18:25
【问题描述】:

这个警告的原因是什么?我在 docker-compose up 命令期间得到它们。

Found another file with the destination path 'admin/js/vendor/jquery/LICENSE.txt'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.
Found another file with the destination path 'admin/img/LICENSE'. It will be ignored since only the first encountered file is collected. If this is not what you want, make sure every static file has a unique path.

我在 settings.py 中的 INSTALLED_APPS 看起来像:

INSTALLED_APPS = [
    "adminlte3",
    "adminlte3_theme",
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "rest_framework",
    "corsheaders",
    "django_extensions",
    "drf_standardized_errors",
    "user",
    "celery",
]

静态:

PROJECT_ROOT = os.getcwd()

STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static")

所以,如果我运行python manage.py findstatic 我发现很多双路径文件。 例如,

C:\Users\irina\app-backend\django_env\Lib\site-packages\adminlte3_theme\static\admin\js\core.js
 C:\Users\irina\app-backend\django_env\Lib\site-packages\django\contrib\admin\static\admin\js\core.js

【问题讨论】:

    标签: django django-rest-framework static django-admin


    【解决方案1】:

    adminlte3 通过使用相同的静态文件夹 /admin/xyz 故意覆盖 django.contrib.admin 模板,因此在使用 collectstatic 时会收到警告。安装的应用程序中的顺序决定首先找到哪个管理应用程序,哪个第二然后被忽略。

    【讨论】:

      猜你喜欢
      • 2016-02-10
      • 2014-05-26
      • 2020-12-07
      • 1970-01-01
      • 1970-01-01
      • 2021-06-17
      • 1970-01-01
      • 2020-09-06
      • 2023-02-17
      相关资源
      最近更新 更多