From 8e9b6b6a151eb3c903753eb3fcdaf7abdbe9c4ac Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 23 Feb 2025 12:09:18 -0500 Subject: [PATCH] Enhance static files management guidelines: clarify directory structure, file management rules, and benefits of separation for better adherence to Django best practices --- .clinerules | 15 ++++++++++++++- memory-bank/systemPatterns.md | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.clinerules b/.clinerules index 50331b6e..1b6b0e1f 100644 --- a/.clinerules +++ b/.clinerules @@ -27,4 +27,17 @@ This applies to all management commands including but not limited to: - Creating superuser: `uv run manage.py createsuperuser` - Starting shell: `uv run manage.py shell` -NEVER use `python manage.py` or `uv run python manage.py`. Always use `uv run manage.py` directly. \ No newline at end of file +NEVER use `python manage.py` or `uv run python manage.py`. Always use `uv run manage.py` directly. + +## Static Files Management +IMPORTANT: All static files must be placed in the `static/` directory, not `staticfiles/`. The `staticfiles/` directory is reserved for Django's collectstatic command output and should not be used directly. + +This consolidation: +1. Follows Django best practices of separating source static files from collected files +2. Prevents confusion between development and production static file locations +3. Makes it clear which static files are part of the source code (static/) versus compiled/collected (staticfiles/) + +When adding new static files: +- Add them to `static/` directory +- Use Django's `static` template tag to reference them +- Run `uv run manage.py collectstatic` when deploying \ No newline at end of file diff --git a/memory-bank/systemPatterns.md b/memory-bank/systemPatterns.md index 6e023f1f..7d56ce76 100644 --- a/memory-bank/systemPatterns.md +++ b/memory-bank/systemPatterns.md @@ -21,6 +21,23 @@ - Implement component-based structure - Follow progressive enhancement +### Static Files Organization +1. Directory Structure + - `static/` - Source static files (CSS, JS, images, etc.) + - `staticfiles/` - Collected files (generated by collectstatic) + +2. File Management Rules + - Place all source static files in `static/` directory + - Never directly modify `staticfiles/` directory + - Use Django's `static` template tag for references + - Run collectstatic before deployment + +3. Benefits of Separation + - Clear distinction between source and compiled files + - Prevents confusion in development vs production + - Follows Django best practices + - Simplifies deployment process + ## Design Patterns ### Data Access