[PR #623] Rework Static_Root & StaticFile structure #652

Open
opened 2026-02-27 15:59:30 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/retspen/webvirtcloud/pull/623
Author: @MisterBlueBear
Created: 11/6/2023
Status: 🔄 Open

Base: masterHead: static_root


📝 Commits (1)

  • 0658b29 Rework Static_Root & StaticFile structure

📊 Changes

319 files changed (+5 additions, -11678 deletions)

View changed files

📝 README.md (+3 -3)
static/drf-yasg/README (+0 -18)
static/drf-yasg/immutable.js (+0 -4977)
static/drf-yasg/immutable.min.js (+0 -34)
static/drf-yasg/insQ.js (+0 -163)
static/drf-yasg/insQ.min.js (+0 -4)
static/drf-yasg/redoc-init.js (+0 -73)
static/drf-yasg/redoc-old/LICENSE (+0 -22)
static/drf-yasg/redoc-old/redoc.min.js (+0 -8)
static/drf-yasg/redoc-old/redoc.min.js.map (+0 -23)
static/drf-yasg/redoc/LICENSE (+0 -22)
static/drf-yasg/redoc/redoc-logo.png (+0 -0)
static/drf-yasg/redoc/redoc.min.js (+0 -3)
static/drf-yasg/redoc/redoc.standalone.js.map (+0 -1)
static/drf-yasg/style.css (+0 -73)
static/drf-yasg/swagger-ui-dist/LICENSE (+0 -202)
static/drf-yasg/swagger-ui-dist/NOTICE (+0 -2)
static/drf-yasg/swagger-ui-dist/absolute-path.js (+0 -14)
static/drf-yasg/swagger-ui-dist/favicon-32x32.png (+0 -0)
static/drf-yasg/swagger-ui-dist/index.js (+0 -17)

...and 80 more files

📄 Description

These changes fix the django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path as seen in #622 and #605.

Static files in the static directory are moved to webvirtcloud/static and framework component files (i.e. rest_framework/* and drf-yasg/*) are deleted as they will be copied / linked by collectstatic.
Also, instead of copying static files into the static directory, I think using symbolic links (--link) will be better as it uses less disk space and the --clear removes orphan static files which may no longer be part of a framework component or the WVC static directory.

python3 manage.py collectstatic --noinput --clear --link

Note: When updating WVC, the below code in webvirtcloud/settings.py

if not DEBUG:
    STATIC_ROOT = ""

STATICFILES_DIRS = [
    Path.joinpath(BASE_DIR, "static"),

]

must be replaced with

STATIC_ROOT = "static"

STATICFILES_DIRS = [
    Path.joinpath(BASE_DIR, "webvirtcloud/static"),
]

The webvirtcloud/settings.py.template is up-to-date with the changes so a new installation will work out-of-the-box.

I commented and posted additionnal explanations for these changes at https://github.com/retspen/webvirtcloud/issues/605#issuecomment-1783447441


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/retspen/webvirtcloud/pull/623 **Author:** [@MisterBlueBear](https://github.com/MisterBlueBear) **Created:** 11/6/2023 **Status:** 🔄 Open **Base:** `master` ← **Head:** `static_root` --- ### 📝 Commits (1) - [`0658b29`](https://github.com/retspen/webvirtcloud/commit/0658b29db7f0f146cb468157922f71791170bffa) Rework Static_Root & StaticFile structure ### 📊 Changes **319 files changed** (+5 additions, -11678 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+3 -3) ➖ `static/drf-yasg/README` (+0 -18) ➖ `static/drf-yasg/immutable.js` (+0 -4977) ➖ `static/drf-yasg/immutable.min.js` (+0 -34) ➖ `static/drf-yasg/insQ.js` (+0 -163) ➖ `static/drf-yasg/insQ.min.js` (+0 -4) ➖ `static/drf-yasg/redoc-init.js` (+0 -73) ➖ `static/drf-yasg/redoc-old/LICENSE` (+0 -22) ➖ `static/drf-yasg/redoc-old/redoc.min.js` (+0 -8) ➖ `static/drf-yasg/redoc-old/redoc.min.js.map` (+0 -23) ➖ `static/drf-yasg/redoc/LICENSE` (+0 -22) ➖ `static/drf-yasg/redoc/redoc-logo.png` (+0 -0) ➖ `static/drf-yasg/redoc/redoc.min.js` (+0 -3) ➖ `static/drf-yasg/redoc/redoc.standalone.js.map` (+0 -1) ➖ `static/drf-yasg/style.css` (+0 -73) ➖ `static/drf-yasg/swagger-ui-dist/LICENSE` (+0 -202) ➖ `static/drf-yasg/swagger-ui-dist/NOTICE` (+0 -2) ➖ `static/drf-yasg/swagger-ui-dist/absolute-path.js` (+0 -14) ➖ `static/drf-yasg/swagger-ui-dist/favicon-32x32.png` (+0 -0) ➖ `static/drf-yasg/swagger-ui-dist/index.js` (+0 -17) _...and 80 more files_ </details> ### 📄 Description These changes fix the `django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path` as seen in #622 and #605. Static files in the `static` directory are moved to `webvirtcloud/static` and framework component files (i.e. `rest_framework/*` and `drf-yasg/*`) are deleted as they will be copied / linked by `collectstatic`. Also, instead of copying static files into the static directory, I think using symbolic links (--link) will be better as it uses less disk space and the `--clear` removes orphan static files which may no longer be part of a framework component or the WVC static directory. ``` python3 manage.py collectstatic --noinput --clear --link ``` **Note**: When updating WVC, the below code in `webvirtcloud/settings.py` ``` if not DEBUG: STATIC_ROOT = "" STATICFILES_DIRS = [ Path.joinpath(BASE_DIR, "static"), ] ``` must be replaced with ``` STATIC_ROOT = "static" STATICFILES_DIRS = [ Path.joinpath(BASE_DIR, "webvirtcloud/static"), ] ``` The `webvirtcloud/settings.py.template` is up-to-date with the changes so a new installation will work out-of-the-box. I commented and posted additionnal explanations for these changes at https://github.com/retspen/webvirtcloud/issues/605#issuecomment-1783447441 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#652
No description provided.