无法在设置中找到“静态文件”的配置.STORAGES。

huangapple go评论92阅读模式
英文:

Could not find config for 'static files' in settings.STORAGES

问题

这个错误发生在运行Django 4.2时。默认的:django.contrib.staticfiles.storage.StaticFilesStorage 已被弃用。

英文:

This error occurs when running Django 4.2.The Default: django.contrib.staticfiles.storage.StaticFilesStorage has been deprecated.

答案1

得分: 3

默认情况下:django.contrib.staticfiles.storage.StaticFilesStorage 已在Django的后续版本中被弃用。

> 从版本4.2开始弃用:
> 此设置已被弃用。从Django 4.2开始,可以使用staticfiles键下的STORAGES设置配置静态文件存储引擎。

修复
STORAGES

在Django 4.2中新增。
默认:

  1. STORAGES = {
  2. "default": {
  3. "BACKEND": "django.core.files.storage.FileSystemStorage",
  4. },
  5. "staticfiles": {
  6. "BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
  7. },
  8. }`
  9. <details>
  10. <summary>英文:</summary>
  11. The Default: `django.contrib.staticfiles.storage.StaticFilesStorage` has been deprecated in later versions of Django.
  12. &gt; Deprecated since version 4.2:\
  13. &gt; This setting is deprecated. Starting with Django 4.2, static files storage engine can be configured with the STORAGES setting under the staticfiles key.
  14. FIX\
  15. `STORAGES`
  16. New in Django 4.2. \
  17. Default:

STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}`

huangapple
  • 本文由 发表于 2023年6月6日 11:39:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76411302.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定