我正在读威廉·S·文森特的书《Django for API》(当前版本的Django 4.0)

在第4章中,我不能成功地运行命令pythonmade.py收集器.

我得到以下错误:

Traceback (most recent call last):
  File "/Users/my_name/Projects/django/django_for_apis/library/manage.py", line 22, in <module>
    main()
  File "/Users/my_name/Projects/django/django_for_apis/library/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
  File "/Users/my_name/Projects/django/django_for_apis/library/.venv/lib/python3.10/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 154, in collect
    raise processed
whitenoise.storage.MissingFileError: The file 'rest_framework/css/bootstrap.min.css.map' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x102fa07f0>.

The CSS file 'rest_framework/css/bootstrap.min.css' references a file which could not be found:
  rest_framework/css/bootstrap.min.css.map

Please check the URL references in this CSS file, particularly any
relative paths which might be pointing to the wrong location. 

我的设置与settings.py中的书中的设置完全相同:

STATIC_URL = "static/"
STATICFILES_DIRS = [BASE_DIR / "static"]  # new
STATIC_ROOT = BASE_DIR / "staticfiles"  # new
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"  # new

我找不到任何解释.也许有人能给我指个正确的方向.

推荐答案

这似乎与Django 4.1有关:要么降级至Django 4.0,要么降级至simply create the following empty files in one of your static directories:

static/rest_framework/css/bootstrap-theme.min.css.map
static/rest_framework/css/bootstrap.min.css.map

There's a recent change to ManifestStaticFilesStorage,现在它试图用散列的对应物来替换源映射.

Django rest框架最近才添加了bootstrap CSS源图,但还没有发布.

Python相关问答推荐

数字梯度的意外值

Odoo -无法比较使用@api.depends设置计算字段的日期

用gekko解决的ADE方程系统突然不再工作,错误消息异常:@错误:模型文件未找到.& &

如何根据另一列值用字典中的值替换列值

比较两个二元组列表,NP.isin

使用Keras的线性回归参数估计

try 与gemini-pro进行多轮聊天时出错

PywinAuto在Windows 11上引发了Memory错误,但在Windows 10上未引发

图像 pyramid .难以创建所需的合成图像

如何列举Pandigital Prime Set

Python虚拟环境的轻量级使用

递归访问嵌套字典中的元素值

索引到 torch 张量,沿轴具有可变长度索引

合并帧,但不按合并键排序

如何从列表框中 Select 而不出错?

解决调用嵌入式函数的XSLT中表达式的语法移位/归约冲突

python—telegraph—bot send_voice发送空文件

根据客户端是否正在传输响应来更改基于Flask的API的行为

如何根据一定条件生成段id

比较两个有条件的数据帧并删除所有不合格的数据帧