Opened 4 months ago

Closed 4 months ago

#35708 closed Uncategorized (invalid)

[Django 5.1.0] The STATIC_URL is set but STATIC_ROOT is required?!

Reported by: NFSpeedy Owned by:
Component: Template system Version: 5.1
Severity: Normal Keywords: collectstatic, static, aws
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With updating the django-ckeditor-5 and Django, the STATIC_ROOT and STATIC_URL are not working properly.

I have configured AWS S3, it is proven in battle, and without no change to the storages and so on, the collect static started requiring STATIC_ROOT when working with STATIC_URL.

When downgrading to 5.0.8, the process started working as expected again.
Below you can see the traceback.

Traceback (most recent call last):
  File "/Users/nfspeedy/.pyenv/versions/3.12.3/lib/python3.12/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/.pyenv/versions/3.12.3/lib/python3.12/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/Users/nfspeedy/.vscode/extensions/ms-python.debugpy-2024.10.0-darwin-arm64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/Users/nfspeedy/Coding/avtodosie/manage.py", line 22, in <module>
    main()
  File "/Users/nfspeedy/Coding/avtodosie/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 413, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/core/management/base.py", line 459, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 209, in handle
    collected = self.collect()
                ^^^^^^^^^^^^^^
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 135, in collect
    handler(path, prefixed_path, storage)
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 368, in copy_file
    if not self.delete_file(path, prefixed_path, source_storage):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 278, in delete_file
    if self.storage.exists(prefixed_path):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/core/files/storage/filesystem.py", line 205, in exists
    return os.path.lexists(self.path(name))
                           ^^^^^^^^^^^^^^^
  File "/Users/nfspeedy/Coding/avtodosie/.venv/lib/python3.12/site-packages/django/contrib/staticfiles/storage.py", line 39, in path
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.

Change History (1)

comment:1 by Claude Paroz, 4 months ago

Resolution: invalid
Status: newclosed

It is most probably caused by using the now-removed STATICFILE_STORAGES setting, while the new STORAGES setting should be used.

Also note that the django-ckeditor-5 repository does not seem to present tests on Django 5.1 in its test suite, so maybe you should report that issue there.

Note: See TracTickets for help on using tickets.
Back to Top