I am reading the book 'Django for APIs' from 'William S. Vincent' (current edition for Django 4.0)
In chapter 4, I cannot run successfully the command python manage.py collectstatic.
I get the following error:
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.
I have the exact same settings like in the book in settings.py:
STATIC_URL = "static/"
STATICFILES_DIRS = [BASE_DIR / "static"] # new
STATIC_ROOT = BASE_DIR / "staticfiles" # new
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage" # new
I couldn't find any explanation for it. maybe someone can point me in the right direction.
rest_frameworkto yourINSTALLED_APPS?